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;
    }
  }
}
相关推荐
痕迹运维9 小时前
Nginx SFTP代理
nginx
BreezeJiang9 小时前
为什么生成了 dist,项目还是可能跑不起来?从一个 React + Express + MySQL 项目看部署闭环
nginx·react.js
Darling噜啦啦9 小时前
前端到上线全流程:从买服务器到 Nginx 反向代理,搞懂全栈部署
nginx·全栈
烬羽10 小时前
我把"时间胶囊"部署上腾讯云宝塔,跨域从根源消失了
nginx·node.js·全栈
En^_^Joy2 天前
Nginx 从入门到精通:配置、原理与实战详解
运维·nginx
2601_962128262 天前
Nginx目录结构
运维·nginx
2601_962122972 天前
nginx 部署前端vue项目
前端·vue.js·nginx
2601_962128262 天前
Nginx知识详解(理论+实战更易懂)
运维·nginx
2601_962203512 天前
Nginx 安装配置
运维·nginx
牧码岛3 天前
阿里云服务器新端口上线SOP(Windows+Nginx+HTTPS)
服务器·nginx·阿里云