basic auth for specific controller

Peter Premium lists at
Mon Oct 18 14:07:55 MSD 2010


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

We tried the following.

server {
  listen 80;
  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:, request: "GET
/stats HTTP/1.1", host: ""

Nginx responds with a 404 page.

It seems like the server tries to serve static files

Any ideas?

Thanks in advance!


Posted via

More information about the nginx mailing list