Question

Nginx 403 forbidden

  • Posted October 15, 2013

Hi,

I am setting up a server, the plan is to host multiple static sites via NGINX.

The first one I am trying to set up, is iuorvosszakerto.hu I have already configured the DNS, and have updated the domain, name servers are correct. In the control panel the domain points to the droplet.

I have set up the NGINX config as follows:

server { listen 80; ## listen for ipv4; this line is default and $ #listen [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/iuorvosszakerto.hu/public_html;
    index index.html index.htm;

    server_name iuorvosszakerto.hu;

    location / {
            try_files $uri $uri/ /index.html;
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

}

Have also created the symbolic link to the config in /etc/nginx/sites-enabled

The file /var/www/iuorvosszakerto.hu/public_html/index.html exists and is a valid HTML file. The chmod for /var/www is 755.

Have restarted NGINX several times, without any luck.

However, when I open up iuovrosszakerto.hu in a browser, I get 403 - why? The logs in /var/log/nginx are empty.

Looking forward for any answers/suggestions.

Subscribe
Share

My fix ended up that i had mistakingly renamed index.php to something else, so just putting it back to index.php fixed it. (worth checking if you run into 403 Forbidden by nginx.

Did you solve the problem? I’m having the same thing


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi, i had this problem, for me problem was about nginx config in /etc/nginx/sites-available My wrong was, I had defined some unnamed locations of files and folders. so I edited the location and problem begin solved.

The answer here saved my life.

Basically, the nginx server won’t need to serve index files from a directory since routing to resources is handled by Rails, so removing the $uri/ bit was the key for me.

Glad it’s working now :]

Was a DNS issue with my provider :)

I used the following commands during set up: <br>sudo chmod -R 755 /var/www <br>sudo chown -R www-data:www-data /var/www <br> <br>Just did these again, but no change.

When you executed <code>chmod</code>, did you make it recursive? Also, make sure that the <code>/var/www/</code> directory is owned by the same <code>user:group</code> as Nginx. <br> <br>On Ubuntu, the command would be: <code>sudo chmod -R www-data:www-data /var/www</code>