Question
Nginx + Gunicorn. Static Files won't load.
Did these two tutorials and can't get my Mezzanine static files to load:
https://www.digitalocean.com/community/articles/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn#tutorial-comment-submit
https://www.digitalocean.com/community/articles/how-to-install-and-get-started-with-django-based-mezzanine-cms-on-ubuntu
Triple checked my settings and can't find why my static files aren't loading.
Nginx and Gunicorn are installed and working.
Symbolic Link between sites-available and sites-enabled is made
── sites-available
│ ├── mezzanine_app
│ └── myproject
├── sites-enabled
│ ├── ahalearning -> ../sites-available/ahalearning
│ ├── mezzanine_app -> ../sites-available/mezzanine_app
│ └── myproject -> ../sites-available/myproject
Collectstatic has been run and static files are in place:
├── deploy
│ ├── crontab
│ ├── gunicorn.conf.py
│ ├── live_settings.py
│ ├── nginx.conf
│ └── supervisor.conf
├── dev.db
├── fabfile.py
├── __init__.py
├── __init__.pyc
├── local_settings.py
├── local_settings.pyc
├── manage.py
├── requirements.txt
├── settings.py
├── settings.pyc
├── static
│ ├── admin
│ ├── css
│ ├── filebrowser
│ ├── fonts
│ ├── grappelli
│ ├── img
│ ├── js
│ ├── media
│ ├── mezzanine
│ ├── robots.txt
│ └── test
├── urls.py
├── urls.pyc
└── wsgi.py
STATIC_ROOT in settings.py points to the right folder (opt/myenv/mezzanine_app/static/)
My nginx server settings point to the right files:
/etc/nginx/sites-available
server {
server_name 107.170.215.138;
access_log off;
location /static/ {
alias /opt/myenv/mezzanine_app/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
Nginx and Gunicorn fire up without problems.
Nginx Error Log:
2014/04/01 07:10:27 [error] 20899#0: *97 connect() failed (111: Connection refused) while connecting to upstream, client: 220.181.51.145, server: 107.170.215.138, request: "GET / H$
$: "HEAD / HTTP/1.0", upstream: "http://127.0.0.1:8001/"
2014/04/01 07:54:00 [error] 20899#0: *101 connect() failed (111: Connection refused) while connecting to upstream, client: 173.234.241.50, server: 107.170.215.138:8001, request: "G$
2014/04/01 08:09:25 [error] 20899#0: *103 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.190.199, server: 107.170.215.138, request: "GET / $
2014/04/01 09:14:13 [error] 20899#0: *105 connect() failed (111: Connection refused) while connecting to upstream, client: 220.181.51.150, server: 107.170.215.138, request: "GET / $
2014/04/01 10:16:23 [error] 20899#0: *107 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.190.199, server: 107.170.215.138, request: "GET / $
2014/04/01 11:15:52 [error] 20899#0: *109 connect() failed (111: Connection refused) while connecting to upstream, client: 220.181.51.150, server: 107.170.215.138, request: "GET / $
2014/04/01 12:08:57 [error] 20899#0: *111 connect() failed (111: Connection refused) while connecting to upstream, client: 201.57.75.254, server: 107.170.215.138:8001, request: "H
Add a comment
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×