Help setting up Nginx - 403 Forbidden

Hi all,

i´m trying to setup Nginx but getting a 403 Forbidden.

I think the problem might be in the file "/etc/nginx/sites-available/default"

server {
    listen 80;

    root /srv/www;
    index index.php index.html index.htm;

    server_name mydomain.com www.mydomain.com;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ /\. {
        deny all;
    }

    location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
    }
}

or here in the error.log:

2015/07/24 15:41:10 [error] 21834#0: *775 directory index of "/srv/www/" is forbidden, client: 108.162.210.206, server: mydomain.com, request: "GET / HTTP/1.1", host: "www.mydomain.com"

Not sure…

3 Replies

@grevan:

2015/07/24 15:41:10 [error] 21834#0: *775 directory index of "/srv/www/" is forbidden, client: 108.162.210.206, server: mydomain.com, request: "GET / HTTP/1.1", host: "www.mydomain.com"

That's just saying that a directory listing is forbidden. Put an index.php, index.html, or index.htm file in there and see what happens.

If you want a directory listing to be displayed, used nginx's "autoindex".

index.php, index.html, or index.htm are already in there.

I think it might be something about url paths…

Check the ownership/permissions on the files themselves.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct