403 Forbidden in nginx on Centos 7

Posted November 29, 2017 31.6k views

Having issues when I moved files from my old host to a Centos 7 droplet where when you visit those directories in a browser return a 403: Forbidden response.

The nginx error log shows the same thing, where permission is denied.

I have done the following to attempt to fix the nginx permissions:

cd /var/www
sudo chown -R nginx:nginx /var/www
find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r--

The resulting ls -lhA command shows nginx as the owner.

Nevertheless, a 403 persists.

I’ve sudo systemctl restart nginx php-fpm several times as well.

Configuration file contents

I believe those are all the config files. If someone needs to look at something else I can provide it

1 comment

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.

Submit an Answer
2 answers

setenforce permissive
if you have SELinux enabled


After checking your config file and your permissions along with the logs that you’ve provided, I am pretty sure that the problem is due to an incorrect index file. This is actually one of the most common cause for 403 errors.

In your Nginx configuration file you have specified which index files should be loaded, and in which order:

index index.php index.html index.htm;

If none of those three files are found in the directory, Nginx would return a “403 Forbidden” error. According to the logs you are trying to access a folder called /var/www/html/stefano/ and you are getting a 403 so most likely you do not have a index file in that directory.

Hope that this helps!