Reputation: 244
I am trying to run django + gunicorn + nginx locally.
For some reason nginx is not getting data from static. Please tell me what am I doing wrong?
Gunicorn:
gunicorn config.wsgi:application --bind 127.0.0.1:8001
Nginx config:
# mysite_nginx.conf
upstream project_server {
server 127.0.0.1:8001;
}
# the upstream component nginx needs to connect to
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ferom/Programming/my_avatar_clock/media; # your Django project's media files - amend as required
}
location /static {
alias /home/ferom/Programming/my_avatar_clock/my_avatar_clock/proj/static; # your Django project's static files - amend as required
}
location / {
proxy_pass http://127.0.0.1:8000;
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"';
}
}
Folders:
In settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
But when I open http://127.0.0.1/admin/
Nginx say me: 404.
cat /var/log/nginx/error.log
- empty
What am I doing wrong?
Upvotes: 0
Views: 855
Reputation: 331
Maybe you unicorn port was not the same on the Nginx file. I recommend you try set the same port, on the Gunicorn and Nginx proxy.
you say that Gunicorn command was on port 8001:
gunicorn config.wsgi:application --bind 127.0.0.1:8001
But you nginx file was proxy on port 8000:
proxy_pass http://127.0.0.1:8000;
Upvotes: 1