Custom 404 page

Hi,

I tried setting up a custom 404 page by adjusting the nginx.conf file, adding “error_page 404 /404.html;”. Everything worked fine until the bot changed it back to its default / removed it. I was now wondering if there is a way to avoid this?

Thanks for your help.

Nope. This is the reason for urging people not to make changes.

OK, I get that. But there is no other way to add a custom 404 page?

Didn’t get it working either yet but here is a promising answer:

Edit: As @openletter says, this can be dangerous.

1 Like

Have you tested this? When I run sudo nginx -T > nginxT.txt, I don’t see an include directive or anything else that would permit this to work.

No, unfortunately I don’t see it either.

It doesn’t work and is potentially harmful. The file will be world readable to everyone because nginx will serve the file as a text file, so anything in there is exposed. Also, it doesn’t change the configuration. That is really a terrible issue response.

1 Like

Thank you for looking deeply into it!

1 Like

I got it working:

Put the options in /home/user-data/www/domain.tld.conf. Let your box take the changes by running mailinabox/tools/web_update.

When I run nginx -T now I get the option:

# configuration file /home/user-data/www/domain.tld.conf:
error_page 404 /404.html;
2 Likes

I see. I misunderstood the second sentence the issue response. That is why I type out the directory locations, as it is the difference between a working config and a dangerous world-readable configuration file.

1 Like

I was trying this out, but I am unsure if it still works?

I created the my.domain.tld.conf with the error_page parameters file in the /home/user-data/www/my.domain.tld directory, ran /home/mailuser/mailinabox/tools/web_update, did nginx -t and did systemctl restart nginx.

No dice in giving it a custom 404 page.