2

I want to avoide inconsistent error pages using django and nginx. If a static file is not found the default nginx error page and not the django one. I think it would result in bad performance to redirect each failed request to the gunicorn server to end up with the django error page. Where can I find the default django error pages and how let nginx use them?

1 Answers1

2

Django can use many ways how to prepare and generate 404 page. AFAIK Django can even render some templates during the 404 error.

If you want to deliver same page as Django sends to you, you can either:

  • sent each failed request to gunicorn (which can kill your performance).

  • or generate one failed page, store it somewhere in its static form (eg. with curl -o /var/www/errors/404.html http://your.site.com/404 ) and serve the appropriate static page with

    location /404.html {
       alias /var/www/errors/404.html
    }
    error_page 404             /404.html;
    

The first way will make you possible to deliver customized error page (with respect to the missing URI). While the latter way will deliver error pages very fast, but the error page will be same for all the missing pages and URIs.

The choice is up to you.

Věroš K.
  • 530
  • 3
  • 10