Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#137 closed defect (invalid)

The "test configuration"/" -t " option does not check files included from "sites-available"

Reported by: Peter Haggerty Owned by: somebody
Priority: major Milestone:
Component: nginx-core Version: 1.0.x
Keywords: Cc: peter@…
uname -a: Linux ip-10-99-90-255 2.6.38-11-virtual #50-Ubuntu SMP Mon Sep 12 21:51:23 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.0.14
built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx-1.0.14 --conf-path=/etc/nginx/nginx.conf --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module --with-http_addition_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl


First things first. I love nginx! This is some really nice work yall have done, so Thank You! :)

The "test configuration"/" -t " option does not check files included from "sites-available"

To replicate:
mkdir -p /etc/nginx/bad-config/
echo "any random non-valid nginx configuration" > /etc/nginx/bad-config/1.txt

In your nginx.conf:

include /etc/nginx/bad-config/1.txt;

Run nginx with -t and you get the expected response:
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/bad-config/1.txt:2

Now, copy that bad configuration file into the sites-available directory and comment out the include line for that file.
cp /etc/nginx/bad-config/1.txt /etc/nginx/sites-available/

In your nginx.conf:

#include /etc/nginx/bad-config/1.txt;

Verify the file is there:
ls -laF /etc/nginx/sites-available/1.txt

Run nginx -t again
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

Putting files in sites-available appears to cloak them from syntax checking.
This is really a problem as all of our virtual hosts are in the sites-available directory

Change History (2)

comment:1 by Maxim Dounin, 12 years ago

Resolution: invalid
Status: newclosed

Files are checked if they are included into nginx config. If they aren't included - they are not checked. Files in "/etc/nginx/sites-available/" directory aren't normally included into nginx config, most likely you have something like "include /etc/nginx/sites-enabled/*" instead in your nginx.conf. See your nginx config for details.

comment:2 by Peter Haggerty, 12 years ago

You're absolutely right, my bad!

Thanks for taking the time to review the ticket!

Note: See TracTickets for help on using tickets.