为nginx反向代理设置自定义错误页面
生活随笔
收集整理的這篇文章主要介紹了
为nginx反向代理设置自定义错误页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
注意要注意的是,這個場景是指,服務都下線了,只剩前臺的起反向代理的nginx在運行。那么返回的是502 bad way狀態碼。
在server模塊中配置, proxy_intercept_errors on;這個參數
server {#listen 80 default_server;#listen [::]:80 default_server;#server_name _;#fastcgi_intercept_error on;listen 48090;#防止中文頁面亂碼charset utf-8;server_name 10.50.18.10;#root /usr/share/nginx/html;# Load configuration files for the default server block.#include /etc/nginx/default.d/*.conf;#攔截后臺請求location / {proxy_set_header X-NginX-Proxy true;proxy_set_header host $http_host;proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for;proxy_set_header X-real-ip $remote_addr;proxy_pass http://project;#防止nginx反向代理后session丟失proxy_cookie_path /project /;proxy_intercept_errors on; error_page 502 = /custom502.html;}#攔截靜態資源location ~ \.(html|gif|jpg|jpeg|bmp|png|ico|js|css)$ {root /etc/nginx/static;}location = /custom502.html{root /usr/share/nginx/html;}}總結
以上是生活随笔為你收集整理的为nginx反向代理设置自定义错误页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: layui.table.render设置
- 下一篇: AI案例精选