Nginx error_page 自訂錯誤版面設定代碼教程,nginxerror_page
Nginx error_page 自訂錯誤版面設定代碼教程
#fastcgi_intercept_errors on; #文法:fastcgi_intercept_errors on|off #預設值:fastcgi_intercept_errors off #使用欄位:http, server, location #這個指令指定是否傳遞4xx和5xx錯誤資訊到用戶端,或者允許nginx使用error_page處理錯誤資訊。 #你必須明確的在error_page中指定處理方法使這個參數有效,正如Igor所說“如果沒有適當的處理方法, #nginx不會攔截一個錯誤,這個錯誤不會顯示自己的預設頁面,這裡允許通過某些方法攔截錯誤。 #proxy_intercept_errors 為on 表示 nginx按照原response #proxy_intercept_errors on|off #proxy_intercept_errors off #使用欄位:http, server, location #code輸出,後端是404,就是404.這個變數開啟後,我們才能自訂錯誤頁面。 proxy_intercept_errors on; upstream dev1 { server 127.0.0.1:8080; #HessianTest3 } server { listen 80; server_name kevin.com; location / { proxy_pass https://dev1; #HessianTest3 } #參考書本第40頁 #error_page 404 =200 /404.html; #error_page 500 502 503 504 =200 /50x.html; #location = /404.html { # root html; # #} #location = /50x.html { # root html; #} #當頁面發生異常的時候可以指定跳轉到location中,也可以指定跳轉到指定的URL地址上面 error_page 404 https://www.baidu.com/; }