I'm developing a Rails application, and I'm now making the production environment default. I created the directive
server {
listen 127.0.0.1:80;
server_name example.com;
root /web/applications/dashboard/public;
index index.html;
location / {
try_files $uri $uri/ @app;
}
location @app {
proxy_set_header host $Host;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://dashboard;
}
}
This gives me a 403 Forbidden
error when I attempt to visit the URL of my app. I don't have an index.html
in the public
directory.
If I add the directive
location ~ ^/(assets)/ {
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
and change the @app
directive to /
, everything works perfectly.
Do I need an index.html
defined in the root directory? I would ideally not like this to happen and just go to the application directly.
Edit: Here's a relevant entry from the error.log
:
2013/11/29 07:38:08 [error] 30796#0: *1570 directory index of "/web/applications/dashboard/public/" is forbidden, client: '', server: example.com, request: "GET / HTTP/1.1", host: "example.com"
The permissions on that folder are:
...
drwxr-xr-x 3 joshua joshua 4096 Nov 29 07:15 public
...
/users
and it shows up. It's just the root page. I'll update the question with some more info from the error log.