Nginx static files return 403 even with correct permission

The problem

when you are trying to server static files with nginx you get the error 403. On the /etc/nginx/nginx.conf user is nginx or www-data, on the /var/www/app permission are:

[[email protected] www]# ls -lah /var/www/picks/
total 56K
drwxr-xr-x. 8 nginx nginx 4.0K Sep 18 17:38 .
drwxr-xr-x. 7 nginx root  4.0K Sep 18 17:38 ..
drwxr-xr-x. 3 nginx nginx 4.0K Sep 18 17:38 index.html

Solution

If you are using fedora or centos the forbidden 403 is caused by selinux. DO NOT DISABLE SE LINUX!! You need to enable http content in the directory where you will server static files:

chcon -Rt httpd_sys_content_t /var/www/app/