nginx 通過proxy_next_upstream實現容災和重復處理問題


ngx_http_proxy_module 模塊中包括proxy_next_upstream指令
語法: proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 |http_404 | off ...; 默認值: proxy_next_upstream error timeout; 上下文: http, server, location
error # 和后端服務器建立連接時,或者向后端服務器發送請求時,或者從后端服務器接收響應頭時,出現錯誤 timeout # 和后端服務器建立連接時,或者向后端服務器發送請求時,或者從后端服務器接收響應頭時,出現超時 invalid_header # 后端服務器返回空響應或者非法響應頭 http_500 # 后端服務器返回的響應狀態碼為500 http_502 # 后端服務器返回的響應狀態碼為502 http_503 # 后端服務器返回的響應狀態碼為503 http_504 # 后端服務器返回的響應狀態碼為504 http_404 # 后端服務器返回的響應狀態碼為404 off # 停止將請求發送給下一台后端服務器
運用場景
1、proxy_next_upstream http_500 | http_502 | http_503 | http_504 |http_404;
當其中一台返回錯誤碼404,500...等錯誤時,可以分配到下一台服務器程序繼續處理,提高平台訪問成功率,多可運用於前台程序負載,設置proxy_next_upstream
proxy_next_upstream http_500 | http_502 | http_503 | http_504 |http_404;
 
         
2、proxy_next_upstream off
因為proxy_next_upstream 默認值: proxy_next_upstream error timeout;
場景:當訪問A時,A返回error timeout時,訪問會繼續分配到下一台服務器處理,就等於一個請求分發到多台服務器,就可能出現多次處理的情況,
如果涉及到充值,就有可能充值多次的情況,這種情況下就要把proxy_next_upstream關掉
proxy_next_upstream off


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM