django + Nginx + Gunicorn - 404 for Static file when debug is false -


i dont know how nginx serves static files

/etc/nginx/site-available/default :

upstream example.com {   server unix:/home/www/example/env/run/gunicorn.sock fail_timeout=0; }  server {     listen 80;     server_name example.com;     client_max_body_size 4g;      access_log /home/www/example/logs/nginx-access.log;     error_log //home/www/example/logs/nginx-error.log;      location /static/ {          alias /home/www/example/codeab/static/;     }      location /uploads/ {         alias   /home/www/example/codeab/uploads/;     }     location / {         include proxy_params;         proxy_pass http://unix:/home/www/example/env/run/gunicorn.sock;     }     # error pages     error_page 500 502 503 504 /500.html;     location = /500.html {         root /home/www/example/templates/;     }     error_page 404 /401.html;     location = /401.html {         root /home/www/example/codeab/templates/;         internal;     } } 

django setting.py

static_url = '/static/' staticfiles_dirs =  (     os.path.join(base_dir, 'static_content/'), ) static_root = os.path.join(base_dir,'static/') 

also , did collectstatic before debug = false

it seems nginx not considering above config file, 404 page not showing custom 401.html page.

after editing config, linked site-enabled by

sudo ln -s /etc/site-available/default /etc/site-enabled/default service nginx reload sudo service nginx restart 

please help, or let me know if missing things.

i dont know exact solution, started working on changing gunicorn binding xxx.xxx.xx.xx:80 xxx.xx.xx.xx:8000 , editing config -

location / {         include proxy_params;         #proxy_pass http://unix:/home/www/example/env/run/gunicorn.sock;         proxy_pass http://xxx.xxx.xx.xx:8000;     } 

i commented proxy_pass of sock file , added new line can see above.


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -