如果后端的服务器返回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域放 全局生效

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code