nginx proxy_next_upstream实现故障转移
如果后端的服务器返回502、504、执行超时等错误,自动将请求转发到upstream负载均衡池中的另一台服务器,实现故障转移。
location / {
proxy_next_upstream http_502 http_504 http_404 error timeout invalid_header;
proxy_pass http://php_server_pool;
proxy_set_header Host www.yourdomain.com;
proxy_set_header X-Forwarded-For $remote_addr;
}
也可在http域放 全局生效