#947 closed defect (invalid)
nginx -t just a bit buggy
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | trivial | Milestone: | |
| Component: | nginx-core | Version: | 1.8.x |
| Keywords: | Cc: | ||
| uname -a: | Linux localhost 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux | ||
| nginx -V: |
nginx version: nginx/1.8.1
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' |
||
Description
nginx -t is a bit buggy
here is an example:
server {
listen 80 default_server;
server_name _;
index index.html
proxy_set_header X-Forwarded-Proto $scheme;
add_header "X-UA-Compatible" "IE=Edge";
location / {
root /var/www/prod/ComingSoon/html;
try_files $uri $uri/ /index.html;
}
}
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# note the missing ";" in index
# if I move index index.html to a different line.. it works!
server {
listen 80 default_server;
server_name _;
proxy_set_header X-Forwarded-Proto $scheme;
add_header "X-UA-Compatible" "IE=Edge";
index index.html
location / {
root /var/www/prod/ComingSoon/html;
try_files $uri $uri/ /index.html;
}
}
nginx: [emerg] directive "index" is not terminated by ";" in /etc/nginx/conf.d/ComingSoon.conf:7
nginx: configuration file /etc/nginx/nginx.conf test failed
I am running CENTOS 7 using
nginx.x86_64 1:1.8.1-1.el7.ngx

The first configuration is valid, and
nginx -tcorrectly says it is. Theindexdirective accepts multiple arguments, andis equivalent to
So there are no problems from syntax point of view, and nginx isn't able to detect missing semicolon. If started with such a configuration, nginx will happily use
index.html,proxy_set_header,X-Forwarded-Protoand$schemeas index files.That's basically the reason why we try to avoid directives like
index, that is, directives with varying number of arbitrary strings as arguments. There are several such directives though (notablyindexandserver_name), and syntax checks won't help if a semicolon is missed after such a directive (unless next directive is a block one, as in your second snippet).