@@ -34,23 +34,50 @@ server {
34
34
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
35
35
gzip_disable "MSIE [1-6]\. " ;
36
36
37
- # Caching settings for static assets
38
- location ~ * \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
39
- root /usr/share/nginx/html;
37
+ # Root directory for the site
38
+ root /usr/share/nginx/html;
39
+
40
+ # API and secure endpoints
41
+ location ~ ^/( api|secure) / {
42
+ proxy_pass http ://api:3000 ;
43
+ proxy_http_version 1.1;
44
+ proxy_set_header Upgrade $http_upgrade ;
45
+ proxy_set_header Connection 'upgrade' ;
46
+ proxy_set_header Host $host ;
47
+ proxy_set_header X-Real-IP $remote_addr ;
48
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
49
+ proxy_set_header X-Forwarded-Proto $scheme ;
50
+ proxy_cache_bypass $http_upgrade ;
51
+
52
+ # Timeout settings
53
+ proxy_connect_timeout 60s ;
54
+ proxy_send_timeout 60s ;
55
+ proxy_read_timeout 60s ;
56
+ }
57
+
58
+ # Handle requests to /admin/assets/ - KEY FIX HERE
59
+ location ^~ /admin/assets/ {
60
+ # Rewrite requests from /admin/assets/ to /assets/
61
+ rewrite ^/admin/assets/( .*) /assets/$1 last;
62
+ }
63
+
64
+ # Static assets caching
65
+ location ~ * \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
40
66
expires 1y ;
41
67
add_header Cache-Control "public, max-age=31536000, immutable" ;
42
68
try_files $uri =404 ;
43
69
}
44
70
71
+ # Handle all routes for the SPA
45
72
location / {
46
- root /usr/share/nginx/ html;
73
+ index index . html;
47
74
try_files $uri $uri / /index .html;
48
75
}
49
76
50
77
# Error pages
51
78
error_page 404 /index .html;
52
79
error_page 500 502 503 504 /50x .html;
53
80
location = /50x .html {
54
- root /usr/share/nginx/html ;
81
+ try_files $uri = 404 ;
55
82
}
56
83
}
0 commit comments