How to custom 404 page on Nginx
Customizing the nginx 404 error page is a detail to improve the user experience. You can set the error page for each site separately, or you can set a global 404 page. To custom 404 pages, you use the below command to configure nginx config file:
sudo nano /etc/nginx/sites-enabled/default
location /my_blog {
error_page 404 = /article_not_found.html;
}
server {
listen 80;
error_page 404 /page_not_found.html;
…
location /my_blog {
error_page 500 502 503 504 = /server_error.html
}
upstream server2 {
server 10.0.0.1:80;
}
server {
location /my_blog {
error_page 404 = @try_server2;
}
location @try_server2 {
proxy_pass http://server2;