Basic auth for specific controller

Hi,

we would like to provide basic auth for specific rails controllers
(/stats …) with nginx (and passenger).

We tried the following.

server {
listen 80;
server_name www.myapp.de;
root /home/deployer/myapp/public;
passenger_enabled on;
rails_env production;

location ~ ^/(admin|awstats|webalizer|stats) {
auth_basic “Restricted”;
auth_basic_user_file /etc/nginx/basic.auth;
}


}

This results in the following error:

2010/10/18 11:18:20 [error] 31331#0: *4 open()
“/home/deployer/myapp/public/stats” failed (2: No such file or
directory), client: xx.xx.xx.xx, server: www.myapp.de, request: “GET
/stats HTTP/1.1”, host: “www.myapp.de

Nginx responds with a 404 page.

It seems like the server tries to serve static files
(/home/deployer/myapp/public/stats).

Any ideas?

Thanks in advance!

Peter

Solved!

You have to set ‘passenger_enabled on’ within the location directive as
well.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs