NGINX - 重新導向有效,代理傳遞無效

NGINX - 重新導向有效,代理傳遞無效

因此,我嘗試設定反向代理,但遇到了一個奇怪的錯誤:當我重定向使用者時,一切正常,但是當我使用 proxy_pass (如我需要的)時,我收到「502 Bad Gateway 錯誤」。

代碼:

server { #banca empresas HTTP

            listen 80;

            server_name emp.baiq.pt www.emp.baiq.pt;

            rewrite ^ https://$server_name$request_uri? permanent;

    }

    server { #banca empresas HTTPS

            listen 443;

            server_tokens off;

            server_name emp.baiq.pt www.emp.baiq.pt;

            add_header X-Frame-Options SAMEORIGIN;
            add_header X-Content-Type-Options nosniff;
            add_header X-XSS-Protection "1; mode=block";

            ssl_certificate /etc/nginx/certs/*.baiteste.pt.crt;
            ssl_certificate_key /etc/nginx/certs/*.baiteste.pt.key;

            location / {
                    #proxy_pass http://192.168.1.78:8081/login.htm?origin=E;
                    return 301 http://192.168.1.78:8081/login.htm?origin=E;
            }

            #error_page 500 502 503 504 /maintenance_page/index.html;

            location = /maintenance_page/index.html {
                    root html;
            }

            location = /favicon.ico {
                    log_not_found off;
            }

            access_log /var/log/nginx/emp.baiq.pt.access.log;

    }

捕獲流量後,我發現對等方在3次握手完成後,一旦收到http請求,就會立即關閉連線。

那麼,什麼可能導致此錯誤?

錯誤日誌文件

2019/07/24 08:25:40 [error] 24506#24506: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "http://y.y.y.y:8081/", host: domaintoaccess.com

謝謝

答案1

因此,經過大約兩天的思考(並在一些幫助下),我/我們發現這是一個路由問題。由於某種原因,防火牆似乎正在悄悄地丟棄此通訊的資料包(我們沒有任何執行此操作的規則)。

相關內容