We’ve all been there; you need to make “just this one little change” to your NGINX configuration and before you know it, your web server is down. Fortunately, there’s an answer in NGINX, test config changes!
There are several tasks you can perform to test config changes in NGINX with built-in switches, troubleshooting best practices, and testing permissions. In this tutorial, you’re going to learn how to get started ensuring you never take production down again!
Validating NGINX Configuration File Syntax
NGINX configuration files follow a specific schema. You can’t just provide any text in a configuration file and expect NGINX to understand it. You need to test it’s syntax first before releasing it into an important environment.
To test an NGINX config file, the
nginx binary provides the
-t switch. The
-t switch is a flag that tells NGINX to read the config file (and all files referenced in the main config file) and ensure the syntax is valid.
sudo nginx -t
-tswitch not only tests syntax in the main NGINX config file, but it also reads and tests syntax for all files referenced via an
If the syntax of the configuration file is valid, you’ll see the following:
On the contrary, you’ll see below that if you’ve made a mistake in the config file, the
-t switch will tell you.
If, for example, NGINX can’t read an included file in the config file due to a permission problem, you’ll see the below output.
You should now know how to use NGINX to test config file syntax! When you make a change to an NGINX config file, remember to always run the
More from Adam The Automator & Friends
Talk to your leads, not just chat! Switch to a call with a single click. FREE - No per agent per month pricing. Suitable for 5+ agents.
ATA is known for its high-quality written tutorials in the form of blog posts. Support ATA with ATA Guidebook PDF eBooks available offline and with no ads!
Prevent, detect and recover from Ransomware attacks. Get a ransomware kit.