user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; proxy_headers_hash_bucket_size 52; gzip on; upstream app { server django:5000; } server { listen 80; server_name ___my.example.com___ www.___my.example.com___; location /.well-known/acme-challenge { proxy_pass http://___LETSENCRYPT_IP___:___LETSENCRYPT_PORT___; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto $scheme; } location / { return 301 https://$server_name$request_uri; } } server { listen 443; server_name ___my.example.com___ www.___my.example.com___; ssl on; ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_dhparam /etc/ssl/private/dhparams.pem; location /.well-known/acme-challenge { proxy_pass http://___LETSENCRYPT_HTTPS_IP___:___LETSENCRYPT_HTTPS_PORT___; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; } location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } # cookiecutter-django app location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app; } } }