prod.nginx.conf 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. include /etc/nginx/mime.types;
  7. default_type application/octet-stream;
  8. types {
  9. application/manifest+json webmanifest;
  10. }
  11. sendfile off;
  12. keepalive_timeout 65;
  13. server {
  14. listen 80;
  15. server_name _;
  16. root /opt/app/build;
  17. # all assets are either static or contain hash in filename, cache forever
  18. location ^~ /assets/ {
  19. add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
  20. try_files $uri =404;
  21. }
  22. # all workbox scripts are compiled with hash in filename, cache forever
  23. location ^~ /workbox- {
  24. add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
  25. try_files $uri =404;
  26. }
  27. location / {
  28. autoindex off;
  29. expires off;
  30. add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always;
  31. try_files $uri /index.html =404;
  32. }
  33. location /backend {
  34. expires off;
  35. add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always;
  36. proxy_set_header X-Real-IP $remote_addr;
  37. proxy_set_header X-Forwarded-For $remote_addr;
  38. proxy_set_header Host $host;
  39. proxy_http_version 1.1;
  40. proxy_set_header Upgrade $http_upgrade;
  41. proxy_set_header Connection "upgrade";
  42. proxy_redirect off;
  43. rewrite ^/backend/?(.*) /$1 break;
  44. proxy_pass http://backend:8080;
  45. }
  46. }
  47. }