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;
    }
  }
}
相关推荐
nangonghen41 分钟前
Nginx stream模块是连接级别的负载均衡
nginx·负载均衡
YJQ996741 分钟前
Nginx与Tomcat负载均衡集群配置指南
nginx·tomcat·负载均衡
三天不学习2 小时前
Vue3 本地环境 Vite 与生产环境 Nginx 反向代理配置方法汇总【反向代理篇】
运维·nginx·vue3·vite·反向代理
2401_831501732 小时前
Linux之Yum源与Nginx服务篇
linux·运维·nginx
猴子请来的逗比4895 小时前
nginx负载均衡及keepalive高可用
运维·学习·nginx·负载均衡
Think Spatial 空间思维15 小时前
【SSL部署与优化】如何为网站启用HTTPS:从Let‘s Encrypt免费证书到Nginx配置
nginx·https·证书·部署·ssl·配置·优化
酷爱码18 小时前
Nginx的核心功能--正向代理、反向代理、缓存和Rewrite
运维·nginx·缓存
筱宇***19 小时前
Mac的web服务器
mysql·nginx·macos·php
alden_ygq1 天前
nginx 出现大量connect reset by peer
服务器·网络·nginx
大大小小聪明1 天前
Nginx核心功能及同类产品对比
运维·nginx