I’m having difficulties making a minimal nginx+gunicorn+django static files work properly, here are further details:
Here’s the nginx site config:
<code>server {
listen 80;
server_name SERVER_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
autoindex on;
alias PATH/TO/PROJECT/static/;
}
location / {
include proxy_params;
proxy_pass http://SERVER_IP:8000;
}
}
</code>
<code>server {
listen 80;
server_name SERVER_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
autoindex on;
alias PATH/TO/PROJECT/static/;
}
location / {
include proxy_params;
proxy_pass http://SERVER_IP:8000;
}
}
</code>
server {
listen 80;
server_name SERVER_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
autoindex on;
alias PATH/TO/PROJECT/static/;
}
location / {
include proxy_params;
proxy_pass http://SERVER_IP:8000;
}
}
I run django with gunicorn using
gunicorn -c gunicorn.conf.py WSGI_FILE
using this config:
<code>command = 'PATH/TO/PROJECT/venv/bin/gunicorn'
pythonpath = 'PATH/TO/PROJECT'
bind = 'SERVER_IP:8000'
workers = 3
</code>
<code>command = 'PATH/TO/PROJECT/venv/bin/gunicorn'
pythonpath = 'PATH/TO/PROJECT'
bind = 'SERVER_IP:8000'
workers = 3
</code>
command = 'PATH/TO/PROJECT/venv/bin/gunicorn'
pythonpath = 'PATH/TO/PROJECT'
bind = 'SERVER_IP:8000'
workers = 3
Also to note I’ve added proper STATIC variables to django settings.py and did collectstatic.
Seems like to be nginx config problem but couldn’t find anything online yet.
I’ve also tried giving group access to nginx(user www-data) for the static files. But I still believe it could be problem of similar type.