Skip to content

Instantly share code, notes, and snippets.

@mahmoudhossam
Created July 28, 2017 01:18
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 mahmoudhossam/d4c5c4de46be70e3fdd40d0e8a5b5710 to your computer and use it in GitHub Desktop.
Save mahmoudhossam/d4c5c4de46be70e3fdd40d0e8a5b5710 to your computer and use it in GitHub Desktop.
example nginx config
upstream django {
server 127.0.0.1:9000; # for a web port socket (we'll use this first)
}
server {
# the port your site will be served on
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live;
ssl_certificate_key /etc/letsencrypt/live;
# the domain name it will serve for
server_name ; # substitute your machine's IP address or FQDN
charset utf-8;
error_log /var/log;
access_log /var/log/;
ssl_prefer_server_ciphers On;
ssl_protocols TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS;
ssl_session_timeout 5m;
# max upload size
client_max_body_size 20M; # adjust to taste
#portal path
# Django media
location /media {
alias /home/ec2-user//media;
}
location /static {
alias /home/ec2-user//static;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_read_timeout 100;
uwsgi_pass django;
include /home/uwsgi_params; # the uwsgi_params file you installed
}
}
uwsgi -s :9000 -M --env DJANGO_SETTINGS_MODULE=settings --chdir /home/ec2-user/ -w "django.core.wsgi:get_wsgi_application()" --chmod-socket=666 --enable-threads --thunder-lock --daemonize /tmp/uwsgi.log --workers 10
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