I am using Nginx, uwsgi, django and Ubuntu 16.04 and getting 404 on all my static files. When I look at nginx's error.log it's adding an extra /static in front of the actual file location:
404 Not found: /home/jsmith/firstproj/static_cdn/static/css/bootstrap.css
Actual location: /home/jsmith/firstproj/static_cdn/css/bootstrap.css
I'm not sure why it's adding the /static in front of the /css/bootstrap.css. Here are my config files:
/var/log/nginx/error.log
2016/07/20 17:34:25 [error] 4424#4424: *22 open() "/home/jsmith/firstproj/static_cdn/static/css/bootstrap.css" failed (2: No such file or directory), client: , server: , request: "GET /static/css/bootstrap.css HTTP/1.1", host:
/home/jsmith/firstproj/src/blogs/settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
/etc/nginx/sites-available/firstproj
server {
listen 80;
location = /favicon.ico { access_log off; log_not_found off; }
location /static {
root /home/jsmith/firstproj/static_cdn;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/firstproj.sock;
}
}
/etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown jsmith:www-data /run/uwsgi'
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
/etc/uwsgi/sites/firstproj.ini
[uwsgi]
project = firstproj
base = /home/jsmith
chdir = %(base)/%(project)/src
home = %(base)/.virtualenvs/%(project)
module = %(project).wsgi:application
master = true
processes = 5
socket = /run/uwsgi/%(project).sock
chmod-socket = 666
vacuum = true
logto = /var/log/uwsgi/%n.log