Roots Discourse

Custom nginx error template

Hi,

I’ve tried telling nginx to use a custom template on 500 errors, but so far it continues to use the default:

I’ve defined this rule via a Trellis nginx-includes:

/trellis/nginx-includes/all/error-templates.conf.j2

# {{ ansible_managed }}

# Display custom server error template.
error_page 500 502 503 504 /custom_50x.html;
location = /custom_50x.html {
    root /usr/share/nginx/html;
    internal;
}

location /testing {
    fastcgi_pass unix:/does/not/exist;
}

The location /testing works (ignore the text, I just copied a default nginx template).
https://www.mydomain.test/testing

Screenshot 2020-09-06 at 12.09.44

However I use this url as my test to trigger an error 500 (because I have no sitemap). No use of the custom template.
https://www.mydomain.test/sitemap.xml

Screenshot 2020-09-06 at 12.11.25

1 Like

Still trying to figure this one out.

When I add item to: /trellis/nginx-includes/all/ such as my error-templates.conf.j2. Where does the contents of this end up on the server? Can’t find it in /etc/nginx/sites-enabled/ so far, but considering the /testing method worked, it must be somewhere.

I am re-provisioning after any change to the error-templates.conf.j2 too.