我使用nginx作为单个机器的反向代理。 我想在后台机器出现故障时出现错误页面。
这是我的configuration文件:
server { listen 80; access_log /var/log/nginx/access.log; root /var/www/nginx; error_page 403 404 500 502 503 504 /error.html; location / { proxy_pass http://192.168.1.78/; include /etc/nginx/proxy.conf; }
啊哈,我看到了问题。 你没有提供任何方式让nginx实际提供静态文件,比如/error.html
,所以它试图将它们上传到你的后端。
快速解决scheme将是:
location /error.html { internal; }
这将导致nginx 处理/error.html
本身 。 然后它将尝试从定义的文档root
文件。
顺便说一句,你可能想要使用不同的错误页面4XX错误和5XX错误。 “找不到”或者不是你想要的人(或者search引擎!)看到后端是否暂时closures。