Opened 2 years ago

Closed 2 years ago

#1764 closed enhancement (duplicate)

Purely syntactic config check?

Reported by: rulatir@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.15.x
Keywords: Cc:
uname -a: Linux <container ID> 5.0.7-arch1-1-ARCH #1 SMP PREEMPT Mon Apr 8 10:37:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: openresty/
built by gcc 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
built with OpenSSL 1.1.0j 20 Nov 2018
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1rc1 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.14 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.6 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-openssl=/tmp/openssl-1.1.0j --with-pcre=/tmp/pcre-8.42 --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-ipv6 --with-mail --with-mail_ssl_module --with-md5-asm --with-pcre-jit --with-sha1-asm --with-stream --with-stream_ssl_module --with-threads --with-stream --with-stream_ssl_preread_module


nginx -t does much more than just a syntactic check, which is why it can fail (i.e. exit with nonzero status) in situations when a purely syntactic check might succeed.

Use case: I am developing a containerized app, and I am at the stage where I do { edit nginx configs; build containers; run the ecosystem; read logs;} while(there are errors); . I want to build a basic syntactic check into Dockerfile so that it would send me back to square one as early as possible if I forget a stupid semicolon, which happens a lot.

nginx -t as currently implemented isn't suitable for this purpose because it also performs validation that would only succeed within the running ecosystem and is guaranteed to fail when building the image. It tries, for example, to resolve upstreams, resulting in "host not found in upstream" errors.

Change History (1)

comment:1 by Maxim Dounin, 2 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #1506.

Note: See TracTickets for help on using tickets.