nginx.conf 3.3 KB

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