server { location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Connection "Upgrade"; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-NginX-Proxy true; client_max_body_size 5000M; # WebSocket requests if ($http_upgrade = "websocket") { proxy_pass http://app:8001; # Daphne runs on port 8001 } # Normal HTTP requests if ($http_upgrade != "websocket") { proxy_pass http://app:8000; # Gunicorn runs on port 8000 } proxy_redirect off; } location /static/ { alias /var/www/staticfiles/; } # https://github.com/cobusc/django-protected-media location /media/ { alias /var/www/media/; } location /internal/ { # internal; alias /var/www/protected/; } }