Last active
April 20, 2018 10:53
-
-
Save ncole458/7e037c499a00b6bcaf4ffec6a0cd592d to your computer and use it in GitHub Desktop.
Fix Gunicorn socket with Nginx not working
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fix Gunicorn socket with Nginx not working | |
# create a new gunicorn sock (for nginx) | |
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-a-gunicorn-systemd-service-file | |
# NGINX - make sure same sock so nginx can talk to Gunicorn! | |
upstream app_server { | |
server unix:/home/django/django_project/MyAPIName/mysockname.sock fail_timeout=0; | |
} | |
# GUNICORN | |
ExecStart=/usr/local/bin/gunicorn --name=MyAPIName --pythonpath=/home/django/django_project --bind unix:/home/django/django_project/MyAPIName/mysockname.sock --config /etc/gunicorn.d/gunicorn.py MyAPIName.wsgi:appli$ | |
# FOLDER PERMS (should be owned by same gunicorn.service i.e. User=username and Group=group) | |
sudo chown -R username:group MyAPIName | |
# START + CHECK GUNICORN | |
sudo systemctl start gunicorn | |
sudo systemctl enable gunicorn | |
sudo systemctl status gunicorn | |
# GUNICORN SOCK ALT OPTION --bind IP | |
--bind 127.0.0.1:8000 # bind gunicorn (instead on mysockname.sock) | |
proxy_pass http://127.0.0.1:8000$request_uri; # update nginx proxy_pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment