95
Syntax:
proxy_next_upstream?error?|?timeout?|?invalid_header?|?http_500?|?http_502?|?http_503?|http_504?|?http_403?|?http_404?|?http_429?|?non_idempotent?|?off?...;
Default:
proxy_next_upstream error timeout;
Context:
http,?server,?location
生效前提:沒有向客戶端發(fā)送任何內(nèi)容 如果向上游服務(wù)器發(fā)送一個字節(jié)說明已經(jīng)發(fā)送生效了 這個指令就失效了
配置:error:與服務(wù)器建立連接、向其傳遞請求或讀取響應(yīng)頭時出錯;
timeout:與服務(wù)器建立連接、向其傳遞請求或讀取響應(yīng)頭時發(fā)生超時;
invalid_header:服務(wù)器返回空響應(yīng)或無效響應(yīng);
http_:http_500、http_403 等這樣錯誤
non_idempotent:
off:關(guān)閉這個功能
Syntax:
proxy_next_upstream_timeout?time;
Default:
proxy_next_upstream_timeout 0;
Context:
http,?server,?location
將請求傳遞到下一個服務(wù)器的時間。0值關(guān)閉此
Syntax:
proxy_next_upstream_tries?number;
Default:
proxy_next_upstream_tries 0;
Context:
http,?server,?location
將請求傳遞到下一個服務(wù)器的可能嘗試次數(shù)。0值關(guān)閉此
代碼演示:
server {
listen 8080;
server_name shopp.com.cn;
location /httperr{
proxy_pass http://nextups;
proxy_next_upstream http_500; #與下面類同 將錯誤限定在 500錯誤的時候
}
location /error {
proxy_pass http://nextups;
proxy_connect_timeout 1s;
proxy_next_upstream error; #當(dāng)設(shè)置為非off得時候,假如一臺上游服務(wù)器無法鏈接比如 8012服務(wù)器宕機了,那么用戶請求會轉(zhuǎn)發(fā)到8011端口,但是如果設(shè)置為off的話 則返回502錯誤
}
}
upstream nextups{
server 192.168.0.51:8012;
server 192.168.0.51:8011;
}
Syntax:
proxy_intercept_errors?on?|?off; 假如上游服務(wù)器發(fā)送返回錯誤碼大于300的時候,如果是off則將上游服務(wù)器錯誤信息返回給客戶端,如果是on的話 則error_page指令就生效了
Default:
proxy_intercept_errors off;
Context:
http,?server,?location
error_page 500 502 503 504 /test.txt;
location /intercept {
root html;
proxy_pass http://192.168.0.51:8013;
proxy_intercept_errors on;#當(dāng)指令啟用為on時 則 error_page就生效了 目前指定了文件路徑 使用了root指令
}
標(biāo)簽:上游,error,server,Nginx,proxy,upstream,http,next,服務(wù)器返回
來源: https://www.cnblogs.com/jackey2015/p/104398.html
因篇幅問題不能全部顯示,請點此查看更多更全內(nèi)容
Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號-2
違法及侵權(quán)請聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)