5

NGINX反向代理非80端口无法访问

 1 year ago
source link: https://vpsxb.net/4143/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

故障现象:

202303042130779.png

1、被代理机器单独访问正常;

2、通过集群访问,连接不带端口,无法访问(502);

配置如下:



  1. upstream test {
  2. ip_hash;
  3. server 10.86.87.85:8080;
  4. server 10.86.87.195:8080;
  5. server {
  6. listen 8000;
  7. server_name 10.86.87.101;
  8. location / {
  9. proxy_pass http://test;
  10. proxy_set_header X-Real-IP $remote_addr;
  11. proxy_set_header Host $host;
  12. real_ip_header X-Real-IP;

反向代理端口为非80端口时,需要配置上代理端口。

完整配置如下:



  1. upstream test {
  2. ip_hash;
  3. server 10.86.87.85:8080;
  4. server 10.86.87.195:8080;
  5. check interval=1000 rise=2 fall=5 timeout=1000 type=http;
  6. check_http_send "GET /index.jsp HTTP/1.0\r\n\r\n";
  7. check_http_expect_alive http_2xx http_3xx;
  8. server {
  9. listen 8000;
  10. server_name 10.86.87.101;
  11. index index.jsp index.html index.htm;
  12. client_max_body_size 100m;
  13. access_log logs/test_access.log logstash_json;
  14. location / {
  15. proxy_pass http://test;
  16. proxy_set_header X-Real-IP $remote_addr;
  17. proxy_set_header Host $host:8000; # 加上被代理的端口号,这里是关键
  18. real_ip_header X-Real-IP;

https://www.jianshu.com/p/a9bc8ffe65ab


VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK