nginx.conf 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. server {
  2. server_name radionica3d.me 148.230.71.134;
  3. root /var/www/radionica3d/dist;
  4. index index.html;
  5. # Gzip Compression
  6. gzip on;
  7. gzip_static on;
  8. gzip_vary on;
  9. gzip_proxied any;
  10. gzip_comp_level 6;
  11. gzip_buffers 16 8k;
  12. gzip_http_version 1.1;
  13. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml font/woff2;
  14. # Security Headers
  15. add_header X-Frame-Options "SAMEORIGIN";
  16. add_header X-XSS-Protection "1; mode=block";
  17. add_header X-Content-Type-Options "nosniff";
  18. add_header Referrer-Policy "strict-origin-when-cross-origin";
  19. # add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
  20. location / {
  21. try_files $uri $uri/ /index.html;
  22. # Caching for index.html (don't cache)
  23. location = /index.html {
  24. add_header Cache-Control "no-store, no-cache, must-revalidate";
  25. }
  26. }
  27. # Static assets in /assets/ (Vite)
  28. location ^~ /assets/ {
  29. expires 1y;
  30. add_header Cache-Control "public, immutable";
  31. access_log off;
  32. }
  33. # Font files (local hosting, long-term cache)
  34. location ^~ /fonts/ {
  35. expires 10y;
  36. add_header Cache-Control "public, immutable";
  37. access_log off;
  38. }
  39. # Other static files
  40. location ~* \.(?:ico|gif|jpe?g|png|svg|webp|avif)$ {
  41. expires 7d;
  42. add_header Cache-Control "public";
  43. access_log off;
  44. }
  45. # Proxy API requests to backend
  46. location /api/ {
  47. proxy_pass http://127.0.0.1:8000/;
  48. proxy_set_header Host $host;
  49. proxy_set_header X-Real-IP $remote_addr;
  50. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  51. proxy_set_header X-Forwarded-Proto $scheme;
  52. }
  53. # Standalone Deploy Webhook
  54. location /deploy-webhook {
  55. proxy_pass http://127.0.0.1:9000;
  56. proxy_set_header Host $host;
  57. }
  58. # WebSocket requests
  59. location /ws/ {
  60. proxy_pass http://127.0.0.1:8000/;
  61. proxy_http_version 1.1;
  62. proxy_set_header Upgrade $http_upgrade;
  63. proxy_set_header Connection "Upgrade";
  64. proxy_set_header Host $host;
  65. proxy_read_timeout 86400;
  66. }
  67. # Static uploads
  68. location ^~ /uploads/ {
  69. alias /var/www/radionica3d/backend/uploads/;
  70. expires 30d;
  71. add_header Cache-Control "public";
  72. }
  73. listen 443 ssl; # managed by Certbot
  74. ssl_certificate /etc/letsencrypt/live/radionica3d.me/fullchain.pem; # managed by Certbot
  75. ssl_certificate_key /etc/letsencrypt/live/radionica3d.me/privkey.pem; # managed by Certbot
  76. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  77. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  78. }
  79. server {
  80. if ($host = radionica3d.me) {
  81. return 301 https://$host$request_uri;
  82. } # managed by Certbot
  83. listen 80;
  84. server_name radionica3d.me;
  85. return 301 https://radionica3d.me$request_uri;
  86. }