我是做了两次代理 第一次
服务器 A nginx 到 tomcat docker (因为 A 上有多个 tomcat 实例,所以要反代)
server {
listen 9090;
server_name
xxx.xxx.com;
location / {
proxy_redirect off;
proxy_set_header Host $host;
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_set_header X-Forwarded-Port $server_port;
proxy_pass http://xxx:8080;
}
}
服务器 B
第二次
listen 80 ;
server_name
xxx2.xxx.com;
location / {
proxy_redirect off;
proxy_set_header Host
xxx.xxx.com;
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_pass
http://xxx.xxx.com:9090;
}
如果直接从 B 带到 A 的 tomcat 是可以的,但是代了两次就不行了