server { listen 80 default_server; server_name _; root /usr/share/nginx/html; charset utf-8; # index.html 软链由 Dockerfile 创建,指向 羚牛车辆数据中心.html index index.html 羚牛车辆数据中心.html; # gzip gzip on; gzip_min_length 1k; gzip_comp_level 6; gzip_vary on; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml; # SPA hash 路由 — 任意未命中文件都回到 index.html location / { try_files $uri $uri/ /index.html; } # 静态资源缓存 7 天 location ~* \.(svg|png|jpg|jpeg|gif|webp|woff2?|ttf|eot)$ { expires 7d; add_header Cache-Control "public, max-age=604800, immutable"; } # JSX/JS/CSS 短缓存(方便热更新) location ~* \.(jsx|js|css)$ { expires 1h; add_header Cache-Control "public, max-age=3600"; } # HTML 不缓存 location ~* \.html$ { expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate"; } # 健康检查 location = /healthz { access_log off; return 200 "ok\n"; add_header Content-Type text/plain; } # 隐藏 nginx 版本 server_tokens off; }