I've just set up my application and deployed it to /srv/my_app_name
using Capistrano. However, when I try to access my app, I receive 403 Forbidden nginx/1.6.2
error. My Nginx runs under www-data
user, but now I'm trying to understand what access rights should be granted to Nginx for my application folder. In my /var/log/nginx/error.log
file I have this:
015/03/01 09:42:16 [error] 19451#0: *1 directory index of "/srv/my_app_name/current/public" is forbidden, client ...
This is the result of ls -l
command for /srv
folder:
drwxrwxr-x 3 root deploy 4096 Feb 28 16:04 srv
Resulf of namei -lm /srv/my_app_name/current/public/
command:
# namei -lm /srv/my_app_name/current/public/
f: /srv/my_app_name/current/public/
drwxr-xr-x root root /
drwxrwxr-x root deploy srv
drwxrwxr-x deploy deploy my_app_name
lrwxrwxrwx deploy deploy current -> /srv/my_app_name/releases/20150301140926
drwxr-xr-x root root /
drwxrwxr-x root deploy srv
drwxrwxr-x deploy deploy my_app_name
drwxrwxr-x deploy deploy releases
drwxrwxr-x deploy deploy 20150301140926
drwxrwxr-x deploy deploy public
My app Nginx config:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
passenger_enabled on;
rails_env production;
# root /srv/my_app_name/;
root /srv/my_app_name/current/public;
# Make site accessible from http://localhost/
server_name localhost staging.my_app_name.de www.staging.my_app_name.de;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
}
My previous application was deployed to /var/www
and worked perfectly, but I've read that it is not the best place for application used as a service, so decided to place this one in more appropriate folder, but now I'm stuck with file permissions.
Question:
should I add some rights for
www-data
only to public folder (/srv/my_app_name/current/public
), or to the whole app folder (/srv/my_app_name
)?What are the proper rights? I currentcly use
deploy
user for deploy, that is added todeploy
group.How to add those rights (I mean commands, cause I'm not very good in Linux file permissions)?