Load balancing - nginx configures backup server, error page does not take effect
伊谢尔伦
伊谢尔伦 2017-05-16 17:18:22
0
1
757

1. When configuring the nginx backup server, when the other two servers are unavailable, jump to the customized page. But it did not take effect after the actual configuration; please check what is wrong with my configuration

IP of the host where nginx is installed: 192.168.109.210
IP of the other two hosts where apache is installed: 192.168.109.208 and 192.168.109.209

2.Code segment

http{

upstream mysvr {

server 192.168.109.208  weight=1 max_fails=2 fail_timeout=2;
server 192.168.109.209  weight=1 max_fails=2 fail_timeout=2;
server 127.0.0.1:80  backup;
}

server {

    listen       80;
    server_name  localhost;

    #设置错误页面
    root /data/www/errorpage;
    index index.html;
    
    location / {
                #设置反向代理
                #proxy_pass  http://192.168.109.208;
                proxy_pass http://mysvr;
                proxy_set_header X-Real-IP $remote_addr;
    }
    
    

}
}

3. Configured error page index.html
[root@yunwei109-210 errorpage]# more index.html
<h1>Sorry, I reported an error! (O_O)</h1>
[root@yunwei109-210 errorpage]# pwd
/data/www/errorpage

4. Error message (after stopping the other 2 servers)

Current error page

Correct error page
Sorry, I reported an error!

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
漂亮男人

Add in http segment:

proxy_next_upstream  http_404 http_502 error;

For details, please visit:
http://nginx.org/en/docs/http...
http://nginx.org/en/docs/http...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template