
リバース プロキシを設定しようとしているのですが、奇妙なエラーが発生しました。ユーザーをリダイレクトするとすべて正常に動作しますが、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
そこで、この件について 2 日間ほど考えた後 (そして助けを借りて)、ルーティングの問題であることがわかりました。ファイアウォールは、何らかの理由でこの通信のパケットを静かにドロップしているようです (これを行うルールはありません)。