How to customize 404 error page for a specific domain

Hello, I saw some thread here about this topic but seems to be outdated regarding my version of HestiaCP (1.9.4). How to set a specific 404 error page for a specific domain ? If not possible, how should I name my 404 page to be loaded as 404 error ? Actually I’ve got a dirty “File not found“. Thanks

Hi,

Hestia doesn’t provide a direct way to customize error pages per domain. It can be done, but I think the issue is that Nginx is not intercepting the 404 error, so it’s showing the Apache2 or PHP error page instead.

I don’t know which app you’re using, but you could try adding this line to the Nginx config files for your domain.

proxy_intercept_errors on;

In context:

        location / {
                proxy_pass http://a.b.c.d:8080;
                proxy_intercept_errors on;
                location ~* ^.+\.(css|htm|html|js|json|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|txt|xls|xlsx|7z|bz2|gz|rar|tar|tgz|zip|apk|appx|bin|dmg|exe|img|iso|jar|msi|webmanifest)$ {
                        try_files  $uri @fallback;

                        root       /home/user/web/example.net/public_html;
                        access_log /var/log/apache2/domains/example.net.log combined;
                        access_log /var/log/apache2/domains/example.net.bytes bytes;

                        expires    max;
                }
        }

The files to be modifed are:

/home/user/conf/web/example.net/nginx.conf
/home/user/conf/web/example.net/nginx.ssl.conf

Once modified, systemctl reload nginx and check whether you see the 404 error page.

Keep in mind that this is a temporary workaround. If it works for your site, you should create a web template with this modification and assign the new web template to your domain.

2 Likes

Thanks for your reply.

I finally created a file in /home/USER/conf/web/DOMAIN/ containing :

ProxyErrorOverride On

That did the job.