I am trying to do basic auth on Nginx. I have version 1.9.3 and it works on Ubuntu 14.04 and it works fine with a simple html file.
Here is the html file:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> "Some shoddy text" </body> </html>
And here is my nginx.conf file:
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
I used htpasswd to create two users in the "users" file under / etc (the username is "calvin" password is "Calvin" and the username is "hobbes" password is "Hobbes"). It is encrypted, as follows:
calvin:$apr1$Q8LGMfGw$RbO.cG4R1riIfERU/175q0 hobbes:$apr1$M9KoUUhh$ayGd8bqqlN989ghWdTP4r/
All files belong to root: root. The IP address of the server is 192.168.1.30, and I refer to this directly in the conf file.
Everything works fine, if I comment out the two auth lines and reload nginx, but if I uncomment them, then I really get the username and password prompts when I try to load the site, but right after that I get the error 500 Internal server error, which seems to be is saved and I have to restart nginx.
Can anyone see what I'm doing wrong here? I had the same behavior in the standard version of Ubuntu 14.04 apt-get version of Nginx (1.4.something), so I do not think that this is the version of nginx.
nginx
Thomas browne
source share