Does nginx auth_basic work over HTTPS?

Solution 1:

Possibly it's a path problem for auth_basic_user_file, where your absolute path is confusing nginx:

http://wiki.nginx.org/HttpAuthBasicModule#auth_basic_user_file

Since version 0.6.7 the filename path is relative to directory of nginx configuration file nginx.conf, but not to nginx prefix directory.

I'm not sure how you have it working in the other cases. The quote from the documentation suggests that you should have to have something like:

auth_basic_user_file htpasswd/www.example.com

where you'd have the password file as "/etc/nginx/htpasswd/www.example.com" if you have "/etc/nginx/nginx.conf" as your server configuration file.

You can check nginx configuration by running "sudo nginx -t". If there's a configuration error, i.e., the auth file is not where it expects it to be, it should tell you at that point.