1.設(shè)定nginx備份伺服器時(shí),當(dāng)其他兩臺(tái)伺服器無法使用時(shí),跳到自訂的頁面。但實(shí)際配置後未生效;麻煩看下我配置的哪有毛病呢
安裝nginx主機(jī)的IP:192.168.109.210
其他兩臺(tái)安裝apache主機(jī)的IP:192.168.109.208和192.168.109.209
2.程式碼片段
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;
#設(shè)置錯(cuò)誤頁面
root /data/www/errorpage;
index index.html;
location / {
#設(shè)置反向代理
#proxy_pass http://192.168.109.208;
proxy_pass http://mysvr;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
3.配置的錯(cuò)誤頁面index.html
[root@yunwei109-210 errorpage]# more index.html
<h1>sorry,我報(bào)錯(cuò)了! (O_O)</h1>
[root@yunwei109-210 errorpage]# pwd
/data/www/errorpage
4.報(bào)錯(cuò)訊息(停掉其他2臺(tái)伺服器後)
目前報(bào)錯(cuò)頁面
#正確的報(bào)錯(cuò)頁面
sorry,我報(bào)錯(cuò)了!
小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。
在http段增加:
proxy_next_upstream http_404 http_502 error;
詳情請見:
http://nginx.org/en/docs/http...
http://nginx.org/en/docs/http...