diff --git a/deploy/nginx-jiu-ali.conf b/deploy/nginx-jiu-ali.conf index 8bd53fc..836f8c8 100644 --- a/deploy/nginx-jiu-ali.conf +++ b/deploy/nginx-jiu-ali.conf @@ -54,6 +54,17 @@ server { client_max_body_size 20m; + # 传输压缩(2026-07-07 公开页提速方案 A′):运行时 gzip,覆盖 Flutter Web 静态 + # 大文件(main.dart.js 5.3MB→~1.3MB、canvaskit.wasm 7.2MB→~3MB)与反代 JSON。 + # 图片(JPEG/PNG)刻意不在列——本身已是压缩格式,上传侧另有 1200px+q85 压缩。 + gzip on; + gzip_comp_level 5; + gzip_min_length 1k; + gzip_vary on; + gzip_proxied any; + gzip_types application/javascript application/wasm application/json + text/css text/plain image/svg+xml application/octet-stream; + # certbot HTTP-01 续期通道(webroot 独立目录,不放 marketing—— # deploy-site 的 rsync --delete 会清掉站点目录里的挑战文件) location ^~ /.well-known/acme-challenge/ { @@ -115,6 +126,13 @@ server { alias /opt/jiu/web/; index index.html; try_files $uri $uri/ /app/index.html; + # 协商缓存(2026-07-07 方案 A′):Flutter 产物文件名无 hash,长缓存会在发版后 + # 新旧错配白屏,故走 etag 304——复访零字节,首访靠上面的 gzip。 + # 注意 add_header 覆盖继承:补回 server 级安全头。 + add_header Cache-Control "no-cache"; + add_header Strict-Transport-Security "max-age=31536000" always; + add_header X-Frame-Options SAMEORIGIN always; + add_header X-Content-Type-Options nosniff always; } location = /app/index.html { @@ -125,7 +143,18 @@ server { expires 0; } - # 公开商品详情页(扫码跳转)→ 后端注入 OG 标签(UA 只拦抓取库,不拦空 UA) + # 店铺公开商品列表页 SSR(2026-07-07 新增短链):与 shops API 同一套边缘闸 + location ~ ^/shop/ { + if ($jiu_bad_ua_lib) { return 403; } + limit_req zone=jiu_shoplist burst=5 nodelay; + limit_conn jiu_conn 10; + proxy_pass http://127.0.0.1:8081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_read_timeout 30s; + } + + # 公开商品详情页(扫码跳转)→ 后端 SSR 轻量页(UA 只拦抓取库,不拦空 UA) location ~ ^/product/ { if ($jiu_bad_ua_lib) { return 403; } limit_req zone=jiu_pub burst=20 nodelay;