注,大家可以看到,现在只能访问Web2,再重新启动Web1,再次访问一下。
[root@web1 ~]# service httpd start正在启动 httpd: [确定]
注,大家可以看到,现在又可以重新访问,说明nginx的健康状态查检配置成功。但大家想一下,如果不幸的是所有服务器都不能提供服务了怎么办,用户打开页面就会出现出错页面,那么会带来用户体验的降低,所以我们能不能像配置LVS是配置sorry_server呢,答案是可以的,但这里不是配置sorry_server而是配置backup。
12.配置backup服务器
[root@nginx ~]# vim /etc/nginx/nginx.confserver { listen 8080; server_name localhost; root /data/www/errorpage; index index.html; }upstream webservers { server 192.168.18.201 weight=1 max_fails=2 fail_timeout=2; server 192.168.18.202 weight=1 max_fails=2 fail_timeout=2; server 127.0.0.1:8080 backup; }[root@nginx ~]# mkdir -pv /data/www/errorpage[root@nginx errorpage]# cat index.html<h1>Sorry......</h1
>
13.重新加载配置文件
[root@nginx errorpage]# service nginx reloadnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful重新载入 nginx: [确定]