nginx: "/root/index.html" forbidden (13: Permission denied)

I was on an amazon linux instance, had to do

sudo chmod o+x /home/ec2-user/
sudo service nginx restart

Not sure what the security implications are.


I solved it by disable SELINUX and reboot

vi /etc/selinux/config

#SELINUX=enforcing
SELINUX=disabled

reboot


Oh! Please don't disable SELinux.

First — do you really need to serve files from /root? That's actually the home directory for the root user, not meant to be the web root. This is actually a very bad idea. Instead, use /var/www/html or (my preference) /srv/www. If you do use /root, make sure you're not exposing ssh keys or authorized_keys files, database passwords, or anything similar. It's really just a bad idea all around.

Second, rather than disabling SELinux (which, in this case, is protecting you from doing something dangerous), you should configure it properly. In Fedora, the SELinux policy as designed so nginx shares this with other webservers, so, using /srv/www/yoursite as the root,

chcon -R -t httpd_sys_content_t /srv/www/yoursite

should do it.