I’d read this How to Create Custom 404 Error Page in NGINX
and then customized it to my_webapp (I have several, so I made per-site configs and error pages). Basically:
- create a custom
404.html
file in theroot
directory of your my_webapp - edit
/etc/nginx/conf.d/domain.tld.d/my_webapp.conf
(this file is refered in the include of yourdomain.tld.conf
file) - add there this config at the bottom (anywhere)
# error 404
error_page 404 /404.html;
location = /404.html {
root /var/www/my_webapp/www/;
internal;
}
404.html is the name of MY error page
root is where your webapp is served from
internal is for making it accesible only from an actual error request
this way you can customize any error (403, 500, etc)