Skip to content

Instantly share code, notes, and snippets.

@hiendnguyen
Last active November 3, 2019 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiendnguyen/bccf6aa9e4e6fe2cb013ddfee39ce91b to your computer and use it in GitHub Desktop.
Save hiendnguyen/bccf6aa9e4e6fe2cb013ddfee39ce91b to your computer and use it in GitHub Desktop.
NGINX config for uWSGI and Django
vi /etc/nginx/conf.d/django.conf
# Put below content in it.
# the upstream component NGINX needs to connect to
upstream django {
server unix:/run/uwsgi/django.sock;
}
# configuration of the server
server {
listen 80;
server_name example.com;
charset utf-8;
# max upload size
client_max_body_size 75M;
# Django media & static
location /media  {
alias /var/www/example/django/public/media;
}
location /static {
alias /var/www/example/django/public/static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass  django;
include uwsgi_params;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment