我通过Nginx服务器将请求转发到本地服务。 我现在尝试完成的是退回到本地错误页面,以防服务不可用。
我目前的configuration是
server { listen 80; server_name ""; location / { proxy_pass http://127.0.0.1:9080; 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_connect_timeout 1; proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404; proxy_intercept_errors on; } error_page 501 502 503 @maintenance; location @maintenance { root /locust/www/fallback/htdocs; index index.html index.htm; } }
代理工作,但只要我使我的服务在9080不可用我的维修位置的index.html不显示。
任何build议这个configuration有什么问题?
其实,我只需要稍微修改你的configuration:
error_page 501 502 503 /500.html; location = /500.html { root /locust/www/fallback/htdocs; }
并且显然要将您想要呈现的index.html重命名为500.html 。
尝试指定错误页面的确切url,如:
proxy_intercept_errors on; error_page 500 502 503 504 402 403 401 /500.html; root /locust/www/fallback/htdocs;