# NginxHttpAuthBasicModule with Sinatra & Passenger

**URL:** <https://www.ruby-forum.com/t/nginxhttpauthbasicmodule-with-sinatra-passenger/185541>\
**Category:** NGINX\
**Created:** [March 22, 2010, 2:25pm UTC](https://www.ruby-forum.com/t/nginxhttpauthbasicmodule-with-sinatra-passenger/185541 "2010-03-22T14:25:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scainey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@scainey](https://www.ruby-forum.com/u/scainey)\
**Post date:** [March 22, 2010, 2:25pm UTC](https://www.ruby-forum.com/t/nginxhttpauthbasicmodule-with-sinatra-passenger/185541/1 "2010-03-22T14:25:46Z")

</div>

Hi,

I’m serving static pages from a Sinatra application using Nginx &  
Phusion Passenger.

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 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](http://mysite.com),  
request: “GET /mypage HTTP/1.1”, host: “[mysite.com](http://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.

Posted at Nginx Forum:

> **[NginxHttpAuthBasicModule with Sinatra & Passenger](https://forum.nginx.org/read.php?2,66586,66586#msg-66586)**
>
> Hi, I'm serving static pages from a Sinatra application using Nginx & Phusion Passenger. I've implemented Basic Authentication for one page on the site using NginxHttpAuthBasicModule, the authentication succeeds but Nginx doesn't resolve the...

---

<div class="post-metadata">

**Author:** ![scainey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@scainey](https://www.ruby-forum.com/u/scainey)\
**Post date:** [March 22, 2010, 3:45pm UTC](https://www.ruby-forum.com/t/nginxhttpauthbasicmodule-with-sinatra-passenger/185541/2 "2010-03-22T15:45:23Z")

</div>

Hello!

On Mon, Mar 22, 2010 at 09:24:57AM -0400, scainey wrote:

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

[…]

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

The request to /mypage maps to /mypage file, this is quite  
normal and nothing in your config suggests any other  
interpretation.

If you expect this to be handled somehow by passenger - it’s  
probably good idea to report the problem to passenger folks.  
AFAIK there are no passenger folks here.

Maxim D.

---

<div class="post-metadata">

**Author:** ![scainey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@scainey](https://www.ruby-forum.com/u/scainey)\
**Post date:** [March 25, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/nginxhttpauthbasicmodule-with-sinatra-passenger/185541/3 "2011-03-25T13:50:34Z")

</div>

Hi!

You must add passenger\_enabled option inside location block.  
This must looks like:

server {  
listen 80;  
server\_name [mysite.com](http://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;
   }

```

}

Posted at Nginx Forum:

> **[Re: NginxHttpAuthBasicModule with Sinatra & Passenger](https://forum.nginx.org/read.php?2,66586,185612#msg-185612)**
>
> Hi, I'm serving static pages from a Sinatra application using Nginx & Phusion Passenger. I've implemented Basic Authentication for one page on the site using NginxHttpAuthBasicModule, the authentication succeeds but Nginx doesn't resolve the...
