Nginx resolve 403 forbidden error

When configuration virtual host in nginx with below configuration file.

virtual host configuration for php.sandbox
virtual host configuration for php.sandbox

Might be, you will have trouble with 403 forbidden error:

nginx virtual host 403
nginx virtual host 403

it could be caused by selinux, just check selinux audit logs with the command:

sudo ausearch -m avc –start recent | grep httpd or sudo ausearch -m avc –start recent | grep httpd or
sudo ausearch -m avc –start recent | grep nginx
sudo ausearch -m avc –start recent | grep nginx

selinux audit for nginx user
selinux audit for nginx user

The solution is that let selinux allow httpd user to read user content by the command

setsebool -P httpd_read_user_content 1
also remember chmod 755 for virtual host directory
#eg chmod 755 /home/longnguyen/php-workspace/

Good luck 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.