This is a small post on how to start troubleshooting Nginx server. If you are facing an issue with nginx or any server/service the first thing to conform is if our configurations are correct or not. Nginx have two commands to show if there is any issue with your configuration or not.
Checking your configs with service command
service nginx configtest
For a failed test you will get below output:
root@linuxnix:/etc/nginx# service nginx configtest
* Testing nginx configuration [fail]
If you observe the above command, it is giving some hint about configuration error but it is not giving more information what error it is.
Test your configurations with nginx command to get more information about what error you have in your configuraton.
-t is for testing your configuraton
root@linuxnix:/etc/nginx# nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/www.linuxnix.com:37
nginx: configuration file /etc/nginx/nginx.conf test failed
From the above message we can see there is an error in 37 line.
If you don't find any issue with your nginx config then our next stop is at logs which are important source of information on what is happening with that server. By default nginx logs are located in /var/log/nginx, but if they are not located there don’t be panic. We have to check nginx configuration file /etc/nginx/nginx.conf for exact log file location. To know your log file entries just search for below words in /etc/nginx/nginx.conf file.
access_log or error_log
Once you are able to find logs from there we can see what happening at server and take nessary stops to make our nginx server working.
Want to check configurations settings for other service then have a look at our post on "Linux/Unix:Server configuration file syntax Checking commands"
Latest posts by Surendra Anne (see all)
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018