Hi
I’ve a droplet with Nginx installed, but I can get the http basic working - I followed this tutorial
And here is the Nginx config
location /test {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd/.test.com;
}
I went to the /test and it return 404
I suspect the official nginx doesn’t come with http basic module, here is the output of
test@v1 /etc/nginx $ nginx -V
nginx version: nginx/1.10.3 (Ubuntu)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --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-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
test@v1 /etc/nginx $
The nginx doesn’t have ngx_http_auth_basic_module compiled as indicated by
http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html
However this is the official nginx, can you help me to get http basic auth working?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Does the path /test exist under your website root? A good first step would be looking through nginx’s error logs for more details on what’s happening. This command will print the last (most recent) 50 lines of the log file:
sudo tail -n 50 /var/log/nginx/error.log
I have the same problem. When I try to use basic auth in my config nginx fails to start. Remove those two lines of config and nginx starts fine.
Trying your log tail, and the last errors are:
invalid number of arguments in "auth_basic" directive in /etc/nginx/sites-enabled/pghero:16
The cause of the error was bad characters. The curly ‘microsoft’ quotes, instead of the straight quotes, and probably some bad whitespace too. Cleaned up the file, and restarting nginx works!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.