Created
February 28, 2019 13:25
-
-
Save qqpann/f2174fc615ac0ffdcb3f0dc1f9a8d1e0 to your computer and use it in GitHub Desktop.
[Django deploy with uWSGI & Nginx] #django #uwsgi #nginx
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
# the upstream component nginx needs to connect to | |
upstream django { | |
server unix:///home/user/api/master.sock; # for a file socket | |
} | |
# configuration of the server | |
server { | |
# the port your site will be served on | |
listen 80; | |
# the domain name it will serve for | |
server_name example.com; # substitute your machine's IP address or FQDN | |
charset utf-8; | |
# max upload size | |
client_max_body_size 75M; # adjust to taste | |
# Django media | |
location /media { | |
alias /home/user/api/media; # your Django project's media files - amend as required | |
} | |
location /static { | |
alias /home/user/api/static; # your Django project's static files - amend as required | |
} | |
# Finally, send all non-media requests to the Django server. | |
location / { | |
uwsgi_pass django; | |
include /home/user/api/uwsgi_params; # the uwsgi_params file you installed | |
} | |
} |
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
# mysite_uwsgi.ini file | |
[uwsgi] | |
# Django-related settings | |
# the base directory (full path) | |
chdir = /home/user/api | |
# Django's wsgi file | |
module = project.wsgi | |
# the virtualenv (full path) | |
#home = /home/user/miniconda3/bin | |
# <- doesnt work :( | |
# process-related settings | |
# master | |
master = true | |
# maximum number of worker processes | |
processes = 10 | |
#threads = 3 | |
# the socket (use the full path to be safe | |
socket = /home/user/api/master.sock | |
pidfile = /home/user/api/master.pid | |
# ... with appropriate permissions - may be needed | |
chmod-socket = 666 | |
# clear environment on exit | |
#vacuum = true | |
# | |
#thunder-lock = true | |
# | |
max-requests = 6000 | |
#max-requests-delta = 300 | |
# log | |
#logto = /var/log/uwsgi/uwsgi.log | |
daemonize = /var/log/uwsgi/uwsgi-daemon.log | |
#log-reopen = true |
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
uwsgi_param QUERY_STRING $query_string; | |
uwsgi_param REQUEST_METHOD $request_method; | |
uwsgi_param CONTENT_TYPE $content_type; | |
uwsgi_param CONTENT_LENGTH $content_length; | |
uwsgi_param REQUEST_URI $request_uri; | |
uwsgi_param PATH_INFO $document_uri; | |
uwsgi_param DOCUMENT_ROOT $document_root; | |
uwsgi_param SERVER_PROTOCOL $server_protocol; | |
uwsgi_param REQUEST_SCHEME $scheme; | |
uwsgi_param HTTPS $https if_not_empty; | |
uwsgi_param REMOTE_ADDR $remote_addr; | |
uwsgi_param REMOTE_PORT $remote_port; | |
uwsgi_param SERVER_PORT $server_port; | |
uwsgi_param SERVER_NAME $server_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment