Nginx 1.2.1: How to analyse 500 Internal Server Error

500-errornginx

I'm responsible for a nginx server that redirects and splits requests. At our production engine we run nginx 1.2.1 and on a test machine we run 1.4.1. The configuration is the same but on the production environment I always get a 500 Internal Server Error"but on the test environment all runs fine. I always checked the access.log and the error.log of Nginx. But there is nothing to worry about.

How can I analyse the error and do some further investigation on the cause of this error?

Best Answer

The first thing to ask yourself: what is emitting the 500 response. Looking at the response headers and the page style will tell you a lot about where it came from. Eg. Is there a X-Powered-By header in the response? If so, it wouldn’t have come from Apache (for example).

A Tomcat error page looks very different to an Nginx page, compared to Apache, etc. This is why I coach people at work to give me a good screen-shot.

Also, if you see logs of 500, but nothing in the error log, then it most likely came from the backend, and you should look there.

Also, why are your test and production nginx versions different? You haven’t said anything about using the same version in production as you do in test.

Beware changes in default behaviour in different versions of software. I was reminded of this a couple of time recently migrating to Apache 2.4 from 2.2.

Finally, you say the backend is the same (really, as in the very same instance?) for test and prod, but that does t necessarily mean a request would be processed the same (eg. different host header or SNI server name being passed)

Hope this helps you master reverse-proxy debugging.

Related Topic