nginx 代理 web service 提供 soap + xml 服务

nginx 代理 web service 提供 soap + xml 服务

最关键的配置:

conf 复制代码
# Nginx默认反向后的端口为80,因此存在被代理后的端口为80的问题,这就导致访问出错。主要原因在Nginx的配置文件的host配置时没有设置响应的端口。Host配置只有host,没有对应的port,这就导致在被代理的地方取得错误的端口。所以修改配置如下
proxy_set_header Host $host:$server_port;

nginx 配置文件

conf 复制代码
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
  include       mime.types;
  default_type  application/octet-stream;

  #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  #                  '$status $body_bytes_sent "$http_referer" '
  #                  '"$http_user_agent" "$http_x_forwarded_for"';

  #access_log  logs/access.log  main;

  sendfile        on;
  #tcp_nopush     on;

  #keepalive_timeout  0;
  keepalive_timeout  65;

  #gzip  on;

  server {
    listen       8081;
    server_name  localhost;

    location / {
      root   html;
      index  index.html index.htm;
    }

    location /services/ws {
      proxy_pass http://localhost:8080/services/ws;
      proxy_set_header Host $host:$server_port;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_connect_timeout 600;
      proxy_read_timeout 600;
      proxy_send_timeout 600;
      proxy_set_header X-Original-URI $request_uri;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
  }
}
相关推荐
null_null99918 小时前
宝塔nginx http转https代理
nginx·http·https
Freed&2 天前
《Nginx进阶实战:反向代理、负载均衡、缓存优化与Keepalived高可用》
nginx·缓存·负载均衡
Hover_Z_快跑2 天前
Docker 部署 Elasticsearch 8.12 + Kibana + Nginx 负载均衡
nginx·elasticsearch·docker
huazeci2 天前
deepin Ubuntu/Debian系统 环境下安装nginx,php,mysql,手动安装,配置自己的项目
nginx·ubuntu·debian
就叫飞六吧2 天前
Nginx 主要的几种负载均衡模式
运维·nginx·负载均衡
脚踏实地的大梦想家3 天前
【Docker】P2 Docker 命令:从Nginx部署到镜像分享的全流程指南
java·nginx·docker
苹果醋34 天前
element-ui源码阅读-样式
java·运维·spring boot·mysql·nginx
向上的车轮4 天前
Actix Web 不是 Nginx:解析 Rust 应用服务器与传统 Web 服务器的本质区别
前端·nginx·rust·tomcat·appche
摇滚侠6 天前
Nginx 与 F5 负载均衡的区别
nginx·负载均衡
huangql5206 天前
Nginx 从零到精通 - 最详细的循序渐进教程
开发语言·网络·nginx