前提:上游服務器沒有向客戶端發送任何內容
1.proxy_next_upstream 指令(當出現錯誤時,nginx爲其重新分配上游服務器)
語法:proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_ 429 | non_idempotent | off ...
默認:proxy_next_upstream error timeout;
放置位置:http,server,location
配置
error :nginx與上游建立連接,讀取響應,發送請求,等等網絡錯誤都可以滿足場景
timeout:超時
invalid_header:收到的上游http_header不合法
http_ :明確的響應code。
non_idempotent :不能重選新服務時。
off:關閉功能
2.proxy_next_upstream_timeout 指令(限制proxy_next_upstream的時間)
語法:proxy_next_upstream_timeout time;
默認:proxy_next_upstream_timeout 0;(0:不限制)
放置位置:http,server,location
3.proxy_next_upstream_tries 指令(限制proxy_next_upstream的次數)
語法:proxy_next_upstream_tries number;
默認:proxy_next_upstream_tries 0;(0:不限制)
放置位置:http,server,location
4.proxy_intercept_errors 指令(當上遊響應的響應碼大於等於300時,應將響應返回客戶端還是按error_page指令處理)
語法:proxy_intercept_errors on | off
默認:proxy_intercept_errors off;
放置位置:http,server,location