Today I Learned

A Hashrocket project

Test Your Nginx Configuration

Nginx misconfiguration can produce vague messages like these:

jake@myserver-2:~# sudo service nginx reload
 * Reloading nginx configuration nginx
   [fail]

Turn up the verbosity with this command:

jake@myserver-2:~# nginx -c /etc/nginx/nginx.conf -t

The -c flag indicates a certain configuration file will follow; the -t flag tells Nginx to test our configuration. This produces much more useful errors like this:

nginx: [emerg] unknown directive "erver_name" in /etc/nginx/sites-enabled/default:3
nginx: configuration file /etc/nginx/nginx.conf test failed

erver_name should be server_name— we have an actionable error message.