Skip to content

Instantly share code, notes, and snippets.

@DennisXie
Created July 10, 2019 08:37
Show Gist options
  • Save DennisXie/258192c3cca6018b6fd0c9a7807b2759 to your computer and use it in GitHub Desktop.
Save DennisXie/258192c3cca6018b6fd0c9a7807b2759 to your computer and use it in GitHub Desktop.
nginx error_page not working
location /xxxx {
proxy_intercept_errors on;
error_page 404 502 = @fallback;
rewrite ^ /yyy.html break;
proxy_pass http://xxxx.com
}
nginx默认情况下只处理自己的404 502这一类错误,如果是代理服务返回的错误码,则不会处理。
这时候需要使用proxy_intercept_erros on; 指令才能让其处理代理返回的错误码。
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment