nginx.conf 3.2 KB

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