If you are trying to configure nginx custom error page for a Python web application like Django but it always shows Django Default 404 Error Page, here is solution for you.
All solutions you found out but they are not working because they are showing you solution on custom error page for application which does not need proxy pass, Django runs on port 8000 (By Default) and you must have used proxy pass in your nginx virtual host for domain configuration.
You need to give one extra attribute in your virtual host and all will work well.
1) Create an index.html in /usr/share/nginx/html/index.html
2) Add following lines under active virtualhost
3) Reload nginx. Now open an error page or 404 page. It will open index.html content in browser.
Note : Your solutions were not working because you did not use attribute `proxy_intercept_errors on;`
For a proxy pass virtualhost, this attribute is important.
All solutions you found out but they are not working because they are showing you solution on custom error page for application which does not need proxy pass, Django runs on port 8000 (By Default) and you must have used proxy pass in your nginx virtual host for domain configuration.
You need to give one extra attribute in your virtual host and all will work well.
1) Create an index.html in /usr/share/nginx/html/index.html
2) Add following lines under active virtualhost
proxy_intercept_errors on;
error_page 500 502 503 504 404 /index.html;
location = /index.html {
root /usr/share/nginx/html;
3) Reload nginx. Now open an error page or 404 page. It will open index.html content in browser.
Note : Your solutions were not working because you did not use attribute `proxy_intercept_errors on;`
For a proxy pass virtualhost, this attribute is important.
No comments:
Post a Comment