Nginx 403 forbidden

October 15, 2013 20.9k views
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 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/; index index.html index.htm; server_name; location / { try_files $uri $uri/ /index.html; } location /doc/ { alias /usr/share/doc/; autoindex on; allow; deny all; } } Have also created the symbolic link to the config in /etc/nginx/sites-enabled The file /var/www/ 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 in a browser, I get 403 - why? The logs in /var/log/nginx are empty. Looking forward for any answers/suggestions.
1 comment
4 Answers
When you executed chmod, did you make it recursive? Also, make sure that the /var/www/ directory is owned by the same user:group as Nginx.

On Ubuntu, the command would be: sudo chmod -R www-data:www-data /var/www
I used the following commands during set up:
sudo chmod -R 755 /var/www
sudo chown -R www-data:www-data /var/www

Just did these again, but no change.
Was a DNS issue with my provider :)
Glad it's working now :]
Have another answer? Share your knowledge.