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;
    }
  }
}
相关推荐
小白的代码日记5 小时前
Nginx学习与安装
运维·nginx
ayaya_mana9 小时前
Nginx性能优化与安全配置:打造高性能Web服务器
运维·nginx·安全·性能优化
油丶酸萝卜别吃19 小时前
nginx配置代理服务器
运维·网络·nginx
花酒锄作田20 小时前
Nginx反向代理Kafka集群
nginx·kafka
奥格列的魔法拖鞋~20 小时前
Docker-LNMP架构 创建多项目- 单个ngixn代理多个PHP容器服务
nginx·docker·eureka·架构·php·lnmp
皓空揽月21 小时前
php+apache+nginx 更换域名
nginx·php·apache
会说法语的猪1 天前
使用nginx反向代理kkfile
运维·nginx
夜影风1 天前
Nginx反向代理与缓存实现
运维·nginx·缓存
forestsea1 天前
Nginx蜘蛛请求智能分流:精准识别爬虫并转发SEO渲染服务
运维·爬虫·nginx
清和已久1 天前
nginx高性能web服务器
服务器·前端·nginx