Nginx: opendir() failed (13: permission denied)
This error could be due to nginx not being to access the folder. We can fix this by adding www-data/nginx as the owner of the directory and sub directory. We can give persmissions to www-data/nginx user to the directory. Also we need to add executable permission to the path of the folder.
chmod +x /home/ chmod +x /home/username chmod +x /home/username/siteroot
Also if you are using a centos 7 box, SELinux is enabled by default. We can set it to persmissive mode by using the following command.
sudo setenforce permissive
But SELinux will be enabled again on restart.
We can fix this by
yum install -y policycoreutils-devel grep nginx /var/log/audit/audit.log | audit2allow -M nginx semodule -i nginx.pp
Also if you do not want to meddle with SELinux, we can run
chcon -Rt httpd_sys_content_t /home/username/siteroot
sudo semanage port -a -t http_port_t -p tcp <port-number>