default.conf 950 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. upstream django_project {
  2. server localhost:8000;
  3. }
  4. error_log /var/log/nginx/error.log;
  5. server {
  6. listen 8080;
  7. access_log /var/log/nginx/access.log;
  8. location / {
  9. proxy_pass http://django_project;
  10. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  11. proxy_set_header X-Real-IP $remote_addr;
  12. proxy_set_header Host $host;
  13. proxy_redirect off;
  14. client_max_body_size 100M;
  15. }
  16. location /static/ {
  17. alias /app/staticfiles/;
  18. }
  19. location /media/ {
  20. alias /app/mediafiles/;
  21. expires 1y;
  22. add_header Cache-Control "public, max-age=31536000, immutable";
  23. # Optimize for small files, combine small packets, and send directly
  24. tcp_nodelay on;
  25. tcp_nopush on;
  26. sendfile on;
  27. # Logging off for high-traffic image serving
  28. access_log off;
  29. }
  30. error_page 500 502 503 504 /50x.html;
  31. location = /50x.html {
  32. root /usr/share/nginx/html;
  33. }
  34. }