R
R
Rigorbb2014-08-04 23:50:19
Nginx
Rigorbb, 2014-08-04 23:50:19

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;
        }
}

What could be the problem? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
A
Anton, 2015-04-01
@antenko

Had the same problem. Everything was in order with the rights, starting from / to the project folder.
The team helped
setenforce Permissive

A
Alexey, 2015-07-21
@Murmurianez

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.

D
Dmitry Bykadorov, 2015-05-25
@hudson

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_... )

N
neck_varentsov, 2014-08-14
@neck_varentsov

Hey!
There was the same problem, I cursed with a 403 error, due to a construction like this

location /public {
                autoindex on;
        }

Here is my config:
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;
        }
}

A
Ainur Valiev, 2017-10-20
@vaajnur

read here
http://phpjs.ru/2017/09/07/nginx-php-fpm-on-vps-ce...

A
Adam_West, 2017-12-20
@Adam_West

https://stopdisablingselinux.com/

A
amagon, 2019-12-03
@amagon

To turn off or not to turn off? That's the question.

S
shnipa, 2020-08-01
@shnipa

Add workers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question