Answer the question
In order to leave comments, you need to log in
How to fix nginx 403 forbidden error?
I'm trying to raise the rails on the server with ubuntu. Ngnix+Unicorn+Capistrano. I deployed everything, I want to make an opening on the IP server for the test. As a result, when opening - 403 forbidden.
In the nginx logs - directory index of "/home/deployer/www/my_app/current/public/" is forbidden,
I tried both 755 and 777 permissions on the folder. www-data group.
nginx config
upstream project_name_rails{
server unix://home/deployer/www/my_app/shared/tmp/unicorn.socket;
}
server{
listen 80;
server_name *айпи*;
root /home/deployer/www/my_app/current/public;
access_log /home/deployer/www/my_app/shared/log/nginx.access.log;
error_log /home/deployer/www/my_app/shared/log/nginx.error.log;
location /public {
autoindex on;
}
}
Answer the question
In order to leave comments, you need to log in
Had the same problem. Everything was in order with the rights, starting from / to the project folder.
The team helpedsetenforce Permissive
Now I will give a shitty answer, but it will help move in the right direction.
At the very beginning of nginx.conf there is a line user www-data;
www-data is a group of users whose rights will run nginx.
The bad part of the answer: in order not to suffer, you can write: user your_root_user_name;
It will work, but this is certainly not for production, but for some kind of test, so as not to fool your head, it can be OK. And for good, of course, make a normal user group with normal rights to run.
Not exactly on time - but it may be useful to someone. Disable SeLinux... The same nonsense might be due to it ( https://access.redhat.com/documentation/en-US/Red_... )
Hey!
There was the same problem, I cursed with a 403 error, due to a construction like this
location /public {
autoindex on;
}
server {
listen 80 default_server;
# listen [::]:80 default_server ipv6only=on;
server_name localhost;
passenger_enabled on;
rails_env production;
root /home/deploy/project/current/public;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question