2014-01-16 12 views
0

我想確定是否有可能告訴Nginx選擇第一個服務器選擇返回一個特定的錯誤時指定上游的另一臺服務器。告訴Nginx嘗試錯誤的另一個上游

如:

try upstream server 0 

if it returns a certain error code (eg: 503) 
    try upstream 1 
else 
    return response to client 

回答

0

下面是你需要做什麼樣,你可以在this answer

upstream myservers{ 
    #the first server is the main server 
    server xxx.xxx.xxx.xxx weight=999 fail_timeout=5s max_fails=1; 
    server xxx.xxx.xxx.xxx; 
} 

server { 
    # all config 
    proxy_pass http://myservers; 
} 
+0

THX穆罕默德瞭解更多詳細信息,這與proxy_next_upstream指令組合做這項工作。 –

相關問題