| 1 | server { |
| 2 | |
| 3 | location / { |
| 4 | proxy_set_header X-Real-IP $remote_addr; |
| 5 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 6 | proxy_set_header Host $http_host; |
| 7 | proxy_set_header Connection "Upgrade"; |
| 8 | proxy_set_header Upgrade $http_upgrade; |
| 9 | proxy_set_header X-NginX-Proxy true; |
| 10 | client_max_body_size 5000M; |
| 11 | |
| 12 | # WebSocket requests |
| 13 | if ($http_upgrade = "websocket") { |
| 14 | proxy_pass http://app:8001; # Daphne runs on port 8001 |
| 15 | } |
| 16 | |
| 17 | # Normal HTTP requests |
| 18 | if ($http_upgrade != "websocket") { |
| 19 | proxy_pass http://app:8000; # Gunicorn runs on port 8000 |
| 20 | } |
| 21 | |
| 22 | proxy_redirect off; |
| 23 | } |
| 24 | |
| 25 | location /static/ { |
| 26 | alias /var/www/staticfiles/; |
| 27 | } |
| 28 | |
| 29 | # https://github.com/cobusc/django-protected-media |
| 30 | location /media/ { |
| 31 | alias /var/www/media/; |
| 32 | } |
| 33 | location /internal/ { |
| 34 | # internal; |
| 35 | alias /var/www/protected/; |
| 36 | } |
| 37 | } |