2019年10月7日 星期一

Nginx Reverse Proxy 自訂error頁面

在設定檔的httpserver或location中設定
proxy_intercept_errors on;
說明:Determines whether proxied responses with codes greater than or equal to 300 should be passed to a client or be intercepted and redirected to nginx for processing with the error_page directive.

接著在需要處理的server段落內,加上要自訂的錯誤碼
error_page 500 502 503 504 /50x.html;
說明:Defines the URI that will be shown for the specified errors. A uri value can contain variables.
如果需要,可以指定自訂的錯誤頁面位置
location /50x.html {
                root /var/www/html;
                }
存檔後,重新啟動nginx即可!