0
我試圖顯示一個自定義502錯誤頁面,當後臺服務器(上游)脫機時,但它不起作用:它繼續顯示默認502錯誤頁面(我是確保上游處於離線狀態)。Nginx將不會使用自定義502錯誤頁面
我的文件結構如下:
- 靜態文件
/var/web/example.org/www/res
下(例如:/var/web/example.org/www/res/robots.txt
); - 錯誤頁面在
/var/web/example.org/www
(例如:/var/web/example.org/www/502.html
)。這是因爲我不希望錯誤頁面(不是來自後面的web服務器,包括404和其他)在該web服務器打開時可訪問。
這裏是我的(匿名)配置:
upstream exampleorg {
server 127.0.0.1:8087;
}
server {
listen 80;
server_name www.example.org;
# content
# - static
root /var/web/example.org/www/res;
# - main webserver
error_page 403 404 @exampleorg;
error_page 502 /../502.html;
location @exampleorg {
proxy_pass http://exampleorg;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
我也曾嘗試以下定義捕捉502以下(在服務器塊,末):
error_page 502 /502.html;
location /502.html {
root /var/web/example.org/www;
internal;
}
但nginx繼續顯示默認的502頁(即使沒有internal;
)。我應該怎麼做 ?在此先感謝您的解決方案:)