You are not logged in.
I recently set up a reverse proxy for my motion server using nginx.
Here is the config (inside a server block):
location /motion {
# auth_basic "Restricted";
# auth_basic_user_file /srv/.ht_motion;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 10;
proxy_send_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:8081;
}
If I go to domain.com/motion, I can see the images from the motion server (on port 8081).
However, when I uncomment the two commented lines to get HTTP authentication, domain.com/motion starts giving a 404 error. systemctl restart nginx doesn't give any errors. The .ht_motion file is in the right place and it seems to have the correct syntax (user:encrypted password). Its permissions are rw-r--r-- so the http user should be able to read it. The same password file worked with my Apache reverse proxy.
Why does this give a 404 error and how can I fix it?
Last edited by subraizada3 (2014-04-21 19:03:33)
Offline
Bump?
Offline
What is in your nginx access and error logs? Does the server even prompt you for a password?
Offline
What is in your nginx access and error logs?
I'm using the log format that was included in the default config file.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
Here's the access log:
192.168.1.1 - - [21/Apr/2014:13:51:49 -0500] "GET /motion/ HTTP/1.1" 404 162 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0" "-"
The error log is empty.
Does the server even prompt you for a password?
No, when I go to domain.com/motion, I get a 404 error before it asks for a password.
By the way, Chromium doesn't work either (and doesn't even support the MJPEG format that the motion server uses). Adding a 'root /srv/http' inside the 'location /motion' doesn't help, neither does using /motion/ instead of /motion.
Last edited by subraizada3 (2014-04-21 18:55:36)
Offline
Apparently the error log was disabled for that vhost, here's the log (set to the 'warn' loglevel)
2014/04/21 13:59:10 [error] 3076#0: *1 no user/password was provided for basic authentication, client: 192.168.1.1, server: www.domain.com, request: "GET /motion/ HTTP/1.1", host: "domain.com"
2014/04/21 13:59:10 [error] 3076#0: *1 open() "/srv/http/errors/401.html" failed (2: No such file or directory), client: 192.168.1.1, server: www.domain.com, request: "GET /motion/ HTTP/1.1", host: "domain.com"
EDIT: Well, that explains a lot. I was using custom error pages but never made the 401 page, which resulted in a 404.
When I commented out the part of the config to use the custom error page, it started giving a 401 error which prompted Firefox to ask for credentials.
It works now.
Last edited by subraizada3 (2014-04-21 19:03:17)
Offline