Last active
May 16, 2016 16:11
-
-
Save otykhonruk/1f60c97a6cf43c89351ca864244e73db to your computer and use it in GitHub Desktop.
nginx/uwsgi configuration for typical django project.
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
# example.conf | |
# the upstream component nginx needs to connect to | |
upstream example { | |
server unix:///tmp/example.sock; # for a file socket | |
} | |
# configuration of the server | |
server { | |
listen 80; | |
server_name .example.com; | |
charset utf-8; | |
# max upload size | |
client_max_body_size 15M; # adjust to taste | |
# Django media | |
location /media { | |
alias /home/example/example/media; # your Django project's media files | |
} | |
location /static { | |
alias /home/example/example/static; # your Django project's static files | |
} | |
# Send all non-media requests to the Django server. | |
location / { | |
# auth_basic "Restricted"; | |
# auth_basic_user_file /etc/nginx/.htpasswd; | |
uwsgi_pass example; | |
include /home/example/example/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
# Configuration file for uWSGI. | |
[uwsgi] | |
# Django-related settings | |
# the base directory (full path) | |
chdir = /home/example/example | |
# Django's wsgi file | |
module = example.wsgi | |
# the virtualenv (full path) | |
home = /home/example/.virtualenvs/example | |
# Django settings | |
env = DJANGO_SETTINGS_MODULE=example.settings.prod | |
# process-related settings | |
# master | |
master = true | |
# maximum number of worker processes | |
processes = 10 | |
# the socket (use the full path to be safe | |
socket = /tmp/example.sock | |
# ... with appropriate permissions - may be needed | |
# chmod-socket = 664 | |
# clear environment on exit | |
vacuum = true | |
plugin = python |
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 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