#557·Nginx

auth_basic_user_file does not warn/alert on missing file

Author: bezioCreated Mar 5, 2025Updated Sep 30, 2026
Labelsbug

Environment

nginx -V

nginx version: nginx/1.26.3
built with OpenSSL 3.0.15 3 Sep 2024
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-1.26.3=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=stderr --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_v3_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-http_geoip_module=dynamic --with-http_image_filter_module=dynamic --with-http_perl_module=dynamic --with-http_xslt_module=dynamic --with-mail=dynamic --with-stream=dynamic --with-stream_geoip_module=dynamic

uname -a

Linux webnode03 6.11.10+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.10-1~bpo12+1 (2024-12-19) x86_64 GNU/Linux

Description

Usually when some file in an include statement is missing, the testify command nginx -t will show an error and the signal to reload config via nginx -s reload won't trigger the config-reload.

Bug/Improvement

If an auth_basic_user_file is missing - it will simply testify ok and reload without any warning nor failing.

In my current case I ran into "403" after moving due to some refactoring/cleanup of the config to another structure/deployment which relied on nginx -t returning rc=0.

nginx configuration

server {
    location / {
        ...
        auth_basic_user_file /etc/nginx/conf.d/auth.htpasswd;
        ...
    }
}

nginx debug log

not needed