Serve custom error pages from reverse proxy

From Wiki
Revision as of 16:34, 3 December 2018 by Admin (Talk | contribs) (Created page with "Nginx: Serve error pages from reverse proxy, not from upstream server If you want nginx to process errors directly you will need to add the following directive to the proxy c...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Nginx: Serve error pages from reverse proxy, not from upstream server

If you want nginx to process errors directly you will need to add the following directive to the proxy config.

proxy_intercept_errors on;

Without this, Nginx will forward the error page coming from the upstream server to the client.

To customize the error pages returned location directives can be added.

  error_page 400 /400.html;
  location /400.html {
    root   /var/www/errorpages;
    internal;
  }

  error_page 500 /500.html;
  location /500.html {
    root   /var/www/errorpages;
    internal;
  }

  error_page 502 /502.html;
  location /502.html {
    root   /var/www/errorpages;
    internal;
  }

  error_page 503 /503.html;
  location /503.html {
    root   /var/www/errorpages;
    internal;
  }

  error_page 504 /504.html;
  location /504.html {
    root   /var/www/errorpages;
    internal;
  }