nginx.conf 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. # Other static files
  34. location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|webp|avif)$ {
  35. expires 7d;
  36. add_header Cache-Control "public";
  37. access_log off;
  38. }
  39. # Proxy API requests to backend
  40. location /api/ {
  41. proxy_pass http://127.0.0.1:8000/;
  42. proxy_set_header Host $host;
  43. proxy_set_header X-Real-IP $remote_addr;
  44. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  45. proxy_set_header X-Forwarded-Proto $scheme;
  46. }
  47. # Standalone Deploy Webhook
  48. location /deploy-webhook {
  49. proxy_pass http://127.0.0.1:9000;
  50. proxy_set_header Host $host;
  51. }
  52. # WebSocket requests
  53. location /ws/ {
  54. proxy_pass http://127.0.0.1:8000/;
  55. proxy_http_version 1.1;
  56. proxy_set_header Upgrade $http_upgrade;
  57. proxy_set_header Connection "Upgrade";
  58. proxy_set_header Host $host;
  59. proxy_read_timeout 86400;
  60. }
  61. # Static uploads
  62. location /uploads/ {
  63. alias /var/www/radionica3d/backend/uploads/;
  64. expires 30d;
  65. add_header Cache-Control "public";
  66. }
  67. listen 443 ssl; # managed by Certbot
  68. ssl_certificate /etc/letsencrypt/live/radionica3d.me/fullchain.pem; # managed by Certbot
  69. ssl_certificate_key /etc/letsencrypt/live/radionica3d.me/privkey.pem; # managed by Certbot
  70. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  71. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  72. }
  73. server {
  74. if ($host = radionica3d.me) {
  75. return 301 https://$host$request_uri;
  76. } # managed by Certbot
  77. listen 80;
  78. server_name radionica3d.me;
  79. return 301 https://radionica3d.me$request_uri;
  80. }