Site still showing internal sever error despite custom 404 error page

October 31, 2019 118 views
Nginx

I followed the tutorial on ’https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04’ to add a custom 404 page to my ip but instead of showing 404 page it shows internal sever error
my error log is :

2019/10/31 13:42:18 [emerg] 12796#12796: duplicate location “/testing” in /etc/nginx/sites-enabled/default:94
2019/10/31 13:42:43 [emerg] 12828#12828: duplicate location “/testing” in /etc/nginx/sites-enabled/default:94
2019/10/31 13:46:06 [emerg] 12871#12871: unknown directive “First” in /etc/nginx/sites-enabled/default:51
2019/10/31 13:48:22 [emerg] 12905#12905: unknown directive “First” in /etc/nginx/sites-enabled/default:51
2019/10/31 13:51:43 [emerg] 12941#12941: unknown directive “First” in /etc/nginx/sites-enabled/default:51
2019/10/31 13:54:48 [emerg] 12979#12979: unknown directive “First” in /etc/nginx/sites-enabled/default:51
2019/10/31 14:02:05 [emerg] 13058#13058: duplicate location “/testing” in /etc/nginx/sites-enabled/default:95
2019/10/31 14:02:23 [emerg] 13090#13090: duplicate location “/testing” in /etc/nginx/sites-enabled/default:95
2019/10/31 15:24:34 [emerg] 13848#13848: duplicate location “/custom_404.html” in /etc/nginx/sites-enabled/default:80

2 Answers

Hi @dronerscomng,

It seems you have an error in your /etc/nginx/sites-enabled/default file on line 51. The error states, there is an Unknown directive “First”. This is why you are getting a 500 Internal Server Error as opposed to a 404 Not Found error/page.

I can give you a hint where to look if you provide us with the default file around the line 51.

Regards,
KDSys

Two things!

First, you have there two different classes of error. You’ve tried to set up a custom 404 page, which will be used for 404 responses. But the internal server error response is 500, and to overwrite this page you would need to create a custom 500 page.

Here is a brief description of HTTP errors:

  • 2xx - success
  • 3xx - redirection
  • 4xx - client error (where 404 is not found)
  • 5xx - server error (where 500 is internal server error)

The other thing is the error itself, from the log messages it seems there’s something wrong with your Nginx configuration file. Try nginx -t to see what errors it might show, re-check your file and read the surrounding instructions in the tutorial.

Have another answer? Share your knowledge.