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

I'm serving static pages from a Sinatra application using Nginx.

I've implemented Basic Authentication for one page on the site using NginxHttpAuthBasicModule, the authentication succeeds but Nginx doesn't resolve the link. Error log gives -

2010/03/22 12:15:19 [error] 7143#0: *2902 open() "/home/me/live/mysite_home/public
/mypage" failed (2: No such file or directory), client: 82.71.18.122, server: mysite.com, 
request: "GET /mypage HTTP/1.1", host: "mysite.com"

The actual file is found at:

 /home/me/live/mysite_home/live/mypage.erb

The configuration file is:

server {
listen 80;
server_name mysite.com;
root /home/me/live/mysite_home/public;
passenger_enabled on;

  location /mypage  {
    auth_basic            "Restricted";
    auth_basic_user_file  htpasswd;
  }

}

server {
listen 443;
server_name mysite.com;
root /home/me/live/mysite_home/public;
passenger_enabled on;
ssl on;
ssl_certificate      /etc/nginx/conf/certs/server.crt;
ssl_certificate_key  /etc/nginx/conf/certs/server.key;
keepalive_timeout    70;

  location /mypage  {
    auth_basic            "Restricted";
    auth_basic_user_file  htpasswd;
  }
}

Not sure if this is a Sinatra, Passenger or Nginx thing, or if I'm just missing something.

share|improve this question
    
Ah ha - n2.nabble.com/Basic-http-authentication-td3510565.html –  scainey Mar 22 '10 at 12:57
    
New link: nginx.2469901.n2.nabble.com/… –  Zabba Jan 28 '11 at 19:48

2 Answers 2

Just need to add

passenger_enabled on;

Inside the location block

server {
listen 80;
server_name mysite.com;
root /home/me/live/mysite_home/public;
passenger_enabled on;

  location /mypage  {
    passenger_enabled on;
    auth_basic            "Restricted";
    auth_basic_user_file  htpasswd;
  }
}

Doh!

share|improve this answer

The actual file is found at:/home/me/live/mysite_home/live/mypage.erb

The configuration file is: root /home/me/live/mysite_home/public;

The configuration file mentions a directory "public" in the path. While the actual file path doesn't contain this. Is this a typo?

share|improve this answer

Your Answer

 
discard

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