Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;

    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
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
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

Your Answer


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.