I'm trying to set up basic authentication on an nginx 1.14.2 server on a Windows 7 machine.
Here's my test configuration:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8282;
auth_basic "Restricted";
auth_basic_user_file .htpasswd;
location / {
root html;
index index.html index.htm;
}
}
}
I am presented with a login box when I visit the website as expected but the authentication always fails. This error comes up in the error logs:
2019/01/24 16:47:55 [error] 178984#159308: *1 user "test" was not found in "C:\path-to-nginx/conf/.htpasswd", client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8282"
The path is correct, I validated that by putting an invalid path in auth_basic_user_file
and observing a different error message.
This is the content of my .htpasswd (passwords are abc123
and test
respectively)
user:$apr1$xQVhJhiA$MCeALGvCxI0bXIcEfYpTR/
test:$apr1$UFI.GptK$v3aa644WePbta3a4ClR2R0
I tried changing newlines from \r\n
to \n
and it didn't help.
Is there anything wrong in my configuration that I missed? Or anything I can try to further debug this issue?
The idea is to eventually use nginx as a reverse proxy to authenticate a resource that doesn't support it, but I'm trying authentication on the most simple configuration possible first.