我是这样上游的:
upstream test_upstream {
least_conn;
server server-prod1.ru:443 max_fails=2 fail_timeout=300s;
server server-prod2.ru:443 max_fails=2 fail_timeout=300s;
}
和这样的代理配置:
server {
listen 8080;
root /usr/share/nginx/html;
location / {
proxy_pass https://test_upstream;
deny all;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_404;
proxy_next_upstream_tries 4;
}
当第一台服务器不可用时,我得到这样的输出(出于安全原因,某些信息被隐藏了):
"22/May/2019:10:03:58 +0300" client=192.168.205.3 - - method=POST request="POST /request/push HTTP/1.1" status=200 upstream_addr=66.66.66.66:443 upstream_status=200
"22/May/2019:10:03:58 +0300" client=192.168.205.3 - - method=GET request="POST /request/push HTTP/1.1" status=502 upstream_addr=sbp_cbrpay upstream_status=502
问题出在这里:“ method = GET request =” POST ...“ 为什么会有错误的方法?应该是POST。