문제

I'm trying to determine if it is possible to tell Nginx to choose another server for a specified upstream when the first server selected returns a specific error.

Eg:

try upstream server 0

if it returns a certain error code (eg: 503)
    try upstream 1
else
    return response to client
도움이 되었습니까?

해결책

Here's a sample of what you need to do, you can read more details on 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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top