Nginx: 403 Forbidden
I spent some hours figuring out why nginx did served static files without problems but rails on passenger were giving me happily "403 Forbidden" error with log entry:
2009/07/25 21:07:03 [error] 2393#0: *2 directory index of "/var/apps/gripesegg/public/" is forbidden, client: 87.119.178.242, server: gripesegg.com, request: "GET / HTTP/1.1", host: "gripesegg.com"
Google suggested I should look over rails app permissions, what I did several times without much success.
There must be some other issue and luckily I wasn't only one with this issue. Turns up, I had at nginx site config file either remove "location /" block or re-specify "passenger_enabled on" inside it.
Wrong way: Will give 403 Forbidden
server {
listen 80;
server_name wikicards.org;
access_log /var/log/nginx/wikicards.access.log;
passenger_enabled on;
location / {
root /var/apps/wikicards/public;
index index.html index.htm;
}
}
Correct way: Add "passenger_enabled on" to the block or remove it as I did:
server {
listen 80;
server_name wikicards.org;
access_log /var/log/nginx/wikicards.access.log;
passenger_enabled on;
}
I hope this tip will save some time for someone.
