Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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 1: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 1 '12 at 8:03
add comment

1 Answer

up vote 0 down vote accepted

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.