0

I have a basic sinatra app which is behind nginx so that I can use HTTP Basic Auth to protect it, but I get a 403 Forbidden error instead of seeing the webapp. The app works fine when I remove the HTTP Auth lines.

The configuration looks something like this:

server {
    auth_basic "Restricted";
    auth_basic_user_file htpasswd;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:4567;
    }

    location ~ /\. {
        deny all;
    }
}

Would greatly appreciate any help on how to get rid of the 403 error.

I'm using nginx version 1.0.0.

Swaroop C H
  • 101
  • 1
  • 5
  • 1
    Check (and post) relevant sections of your web logs - looking to determine the specific cause of the 403; confirm that it is nginx that is generating the 403 error (not sure if sinatra can by default) - confirm whether or not sinatra receives the request; if the URL being generated contains a port number, look into the proxy_redirect directive. – cyberx86 Dec 12 '11 at 01:42
  • @cyberx86 Thanks! Based on your suggestion, I fetched latest nginx 1.0.11, compiled (with debugging enabled) and installed it, and the error went away! – Swaroop C H Jan 01 '12 at 08:03

1 Answers1

0

Going by @cyberx86 suggestion, I was looking on how to enable debug logging and realized I would have to compile nginx myself with debugging enabled, so I compiled and installed the latest nginx 1.0.11 and the error magically went away!

Swaroop C H
  • 101
  • 1
  • 5