iii. Common Location-Related Error Messages

If something is incorrect with the location directive, we will receive the following error messages after restarting Nginx:

a. Having multiple location directives with the same prefix match, “duplicate location” error message:

# service nginx start
Starting nginx: nginx: [emerg] duplicate location "/" in /etc/nginx/conf.d/default.conf:63 [FAILED]

b. Using location in a wrong context (i.e outside the server):

# service nginx restart
nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:50
nginx: configuration file /etc/nginx/nginx.conf test failed

c. Using location modifier that isn't allowed by Nginx:

# service nginx restart
nginx: [emerg] invalid location modifier "$" in /etc/nginx/conf.d/default.conf:23
nginx: configuration file /etc/nginx/nginx.conf test failed

Last updated