I have followed instructions and still I cant password protect my site. This is what my app-nginx.config looks like:
server {
listen 80;
server_name Server_Test;
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
...
}
Where am I going wrong? I copied and pasted this right from a tutorial site.
auth_basic. auth_basic_user_file. The ngx_http_auth_basic_module module allows limiting access to resources by validating the user name and password using the “HTTP Basic Authentication” protocol. Access can also be limited by address, by the result of subrequest, or by JWT.
login nginx admin ui default user/password is admin / admin , password change is required after first login.
Make sure Nginx can access the password file. Paths for the auth_basic_user_file are relative to the directory of nginx.conf
. So if your nginx.conf
is located in /usr/local/nginx
you can change your directive to:
auth_basic_user_file conf/htpasswd;
and the file must be readable.
This file should be readable by workers, running from unprivileged user. E. g. when nginx run from www you can set permissions as:
chown root:nobody htpasswd_file chmod 640 htpasswd_file
-- from http://wiki.nginx.org/HttpAuthBasicModule
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With