天天看点

proxy_next_upstream 对POST无效proxy_next_upstream 对POST无效

proxy_next_upstream 对POST无效

根据网上的教程,启用proxy_next_upstream后发现没有生效:

upstream login_server{
         server 10.32.105.18:8080 max_fails=1 fail_timeout=30s;
         server 10.32.80.75:8080 max_fails=1 fail_timeout=30s backup;
    }

    server {
       listen 8080;
       location /{
           proxy_pass http://login_server;
           # 重试机制,遇到这些错误,继续把请求发到下一个节点
           # non_idempotent:POST支持,需要放在最前面
           proxy_next_upstream error timeout http_500 http_502 http_503 http_504 non_idemponent;
           proxy_next_upstream_tries 2;
       }
    }
           

最后,经过排查原来是只针对

GET生效

,针对POST等请求,需要增加

non_idempotent

,并且要放在最前面才行。

来张测试图片:

proxy_next_upstream 对POST无效proxy_next_upstream 对POST无效

有2台服务器,其中一台返回了500,但是postman还是得到了相应(来自于另外一台好的服务器)。

不得不感叹,Nginx真牛逼👍👍👍👍。

继续阅读