Nginx Not Serving Static Files (Django + Gunicorn) Permission denied
<p>nginx.conf</p>

<pre><code>server {
    listen 80;
    server_name serveraddress.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ec2-user/projectname;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://unix:/home/ec2-user/projectname/projectname.sock;
    }
}
</code></pre>

<p>settings.py</p>

<pre><code>STATIC_URL = '/static/'

STATICFILES_DIR = '/home/ec2-user/projectname/static/'

STATIC_ROOT = '/home/ec2-user/projectname/static/'
</code></pre>

<p>If I run the server using the Django development server with manage.py runserver or with gunicorn, all the static files work perfectly, but using nginx on port 80, none of the static files work; which leads me to believe that it's an issue involving nginx. And yes, I've ran python manage.py collectstatic and 'django.contrib.staticfiles' is installed. I'm using RHEL 7 (Centos 7).</p>

<p>Nginx error.log</p>

<pre><code>2016/09/22 20:44:33 [error] 322#0: *371 open() "/home/ec2-user/projectname/static/css/home.css" failed (13: Permission denied), client :##.###.##.##, server: ##.###.###.###, request: "GET /static/css/home.css HTTP/1.1", host: "##.###.###.###", referrer: "http://##.###.###.###/"
</code></pre>

<p>You have a permission denied issue it seems. <code>(13: Permission denied)</code></p>

<p>nginx often runs under it's own <code>nginx</code> user, and this user probably does not have the permissions to access the location/files and can't serve them.</p>

python django nginx static gunicorn