Hestia Error 500 Template not working?

Hello,

I’m using apache with nginx proxy.

When setting up a fresh website to test, I am able to trigger all template error pages from /document_errors/.

But I am unable to get the error 500 to work.

I created a broken php file with some bad syntax that triggers an error 500 in the browser, I see it in the apache log as well. But it doesn’t load the html template, I just get the default browser error.

Any idea why or if it’s possible at all?

Thanks

Hi @sawine,

Add this directive to your proxy template:

proxy_intercept_errors on;

Before changing the template or better, creating a new one, you can test it editing the current nginx conf files for your domain.

Edit /home/YourUser/conf/web/YourDomain/nginx.conf and /home/YourUser/conf/web/YourDomain/nginx.ssl.conf and add the directive proxy_intercept_errors on; to the location / block, something like this:

        location / {
                proxy_pass http://203.0.113.1:8080;
                proxy_intercept_errors on;

                location ~* ^.+\.(css|html|js|xml|apng|avif|bmp|cur|gif|ico|jfif|jpg|jpeg|pjp|pjpeg|png|svg|tif|tiff|webp|aac|caf|flac|m4a|midi|mp3|ogg|opus|wav|3gp|av1|avi|m4v|mkv|mov|mpg|mpeg|mp4|mp4v|webm|otf|ttf|woff|woff2|doc|docx|odf|odp|ods|odt|pdf|ppt|pptx|rtf|xls|xlsx|7z|bz2|gz|rar|tar|tgz|zip|apk|appx|bin|dmg|exe|img|iso|jar|msi|webmanifest)$ {
                        try_files  $uri @fallback;
[...]

Once done, reload or restart nginx:

systemctl reload nginx

Thank you that worked. I added it to the global nginx config.

1 Like

I see that it also overrides Wordpress 404 pages, is it possible to only have it work on error 500?

Thanks

Yes but you should edit the templates.

You should add a new location @pass_through and use error_page directive to define the errors that should be resolved by the backend or by the default error pages.

Example modifying nginx.ssl.conf. This example will use the default error pages for errors 403, 410 and 50x but for 404 it will use the backend, in your case, wordpress.

location @pass_through {
        internal;
        proxy_pass https://203.0.113.1:8443;
}
location / {
        proxy_pass https://203.0.113.1:8443;
        proxy_intercept_errors on;
        error_page 404 = @pass_through;
        error_page 403 /error/404.html;
        error_page 410 /error/410.html;
        error_page 500 501 502 503 504 505 /error/50x.html;
[...]

Hello,

Thank you for the solution.

I put that in place in the template as suggested. It works, but now the 404 is giving the nginx 404 template instead of the wordpress one.

Before posting I tested it on a default Wordpress installation and it worked, 404 errors were managed by Wordpress.

Could you please explain in detail what did you modify?

:/usr/local/hestia/data/templates/web/nginx/custom.stpl

My mistake, I was testing on a 2nd dev instance, and I forgot to remove the global entry for
proxy_intercept_errors on; that I had inside of /etc/nginx/nginx.conf

It works perfectly!

Thank you :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.