# nginx.conf.template S3·FE-6:envsubst 模板(官方 nginx 镜像 /etc/nginx/templates # 机制,${API_UPSTREAM} 启动注入)。gzip 常开(vite 产物 gzip 后最大 chunk 341KB, # FE-6 单包<500KB 以传输字节计)。 server { listen 80; server_name _; gzip on; gzip_types text/css application/javascript application/json image/svg+xml; gzip_min_length 1024; root /usr/share/nginx/html; index index.html; # hash 文件名资源:一年强缓存(vite contenthash,发版自动失效) location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # SPA 路由 fallback location / { try_files $uri $uri/ /index.html; } # API 反代至网关(k8s 内=Service 名;独立容器=-e API_UPSTREAM 覆盖) location /api/ { proxy_pass http://${API_UPSTREAM}; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 20m; } }