front/nginx-k3s.conf
zzh e5175e6cc1
All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m4s
feat: H5 门户切换与充值审核,订单编辑支持仓库件重尺及 COS 资源代理修复
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-15 19:53:24 +08:00

225 lines
8.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# k3s 方案 A:仅静态 SPA。API 由浏览器按域名直连(prod: api.ideship.com / test: api.test.ideship.com)。
server {
listen 80;
server_name _;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml image/svg+xml;
root /usr/share/nginx/html;
location = / {
try_files $uri @spa;
}
location = /9610.html {
try_files /9610.html =404;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
location = /site {
return 301 /;
}
location = /site/ {
return 301 /;
}
location = /site/index.html {
return 301 /;
}
location ^~ /site/ {
try_files $uri =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
location = /favicon.ico {
try_files /favicon.png =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
location = /favicon.png {
try_files /favicon.png =404;
expires 7d;
add_header Cache-Control "public";
access_log off;
}
location = /login {
try_files $uri @spa;
}
location = /login/ {
try_files $uri @spa;
}
rewrite ^/admin/?$ /index.html last;
location = /admin {
try_files $uri @spa;
}
location = /admin/ {
try_files $uri @spa;
}
location ~ ^/api/(upstreamInterface|upstreamInterfaceConfig|upstreamInterfaceConfigEdit|downstreamInterface(|/newPort)|appList(|/createApplication)|requestLog|callStatistics|apiDebugger|apiTest|openApi)(/|$) {
try_files $uri @spa;
}
location ^~ /xhs/startService { try_files $uri @spa; }
location ^~ /xhs/creation { try_files $uri @spa; }
location ^~ /xhs/publishHistory { try_files $uri @spa; }
location ^~ /xhs/skills { try_files $uri @spa; }
location ^~ /xhs/humanSettings { try_files $uri @spa; }
location ^~ /xhs/agentPair { try_files $uri @spa; }
location = /xhs/analysis { try_files $uri @spa; }
location = /xhs/analysis/ { try_files $uri @spa; }
location ^~ /wechat/register { try_files $uri @spa; }
location ^~ /wechat/bind { try_files $uri @spa; }
location ^~ /h5 { try_files $uri @spa; }
location ^~ /track/query { try_files $uri @spa; }
location ^~ /operation/inboundScan { try_files $uri @spa; }
location ^~ /operation/outboundScan { try_files $uri @spa; }
location ^~ /operation/printLabel { try_files $uri @spa; }
location ^~ /operation/parcelArrival { try_files $uri @spa; }
location ^~ /operation/fulfillPack { try_files $uri @spa; }
# 订单前端路由(^~ 须比下方 /order/ API 正则代理更优先)
location ^~ /order/priceCheck { try_files $uri @spa; }
location ^~ /order/placeOrder { try_files $uri @spa; }
location ^~ /order/myOrders { try_files $uri @spa; }
location ^~ /order/fulfillOrders { try_files $uri @spa; }
location ^~ /order/waybillManage { try_files $uri @spa; }
location ^~ /order/pickupOrder { try_files $uri @spa; }
location ^~ /order/customs9610Order { try_files $uri @spa; }
location ^~ /order/batchJobs { try_files $uri @spa; }
location ^~ /order/templateMapping { try_files $uri @spa; }
location ^~ /order/platformStore { try_files $uri @spa; }
location ^~ /order/platformStoreOrder { try_files $uri @spa; }
# 知识库前端路由(^~ 须比下方 /kb/ API 代理更优先)
location ^~ /kb/category { try_files $uri @spa; }
location ^~ /kb/article { try_files $uri @spa; }
location = /warehouse/parcel { try_files $uri @spa; }
location = /warehouse/inventory { try_files $uri @spa; }
location = /warehouse/sku { try_files $uri @spa; }
location = /warehouse/binLocation { try_files $uri @spa; }
location ^~ /warehouse/inboundNotice { try_files $uri @spa; }
location ^~ /Plugin/ { try_files $uri @spa; }
location ^~ /channel/salesProducts { try_files $uri @spa; }
location ^~ /channel/serviceChannels { try_files $uri @spa; }
location ^~ /channel/priceArea { try_files $uri @spa; }
location ^~ /channel/blacklist { try_files $uri @spa; }
location ^~ /channel/remoteZones { try_files $uri @spa; }
location ^~ /channel/weightRules { try_files $uri @spa; }
location ^~ /channel/weightRounding { try_files $uri @spa; }
location ^~ /channel/autoTrigger { try_files $uri @spa; }
location ^~ /channel/issueTemplate { try_files $uri @spa; }
location ^~ /channel/labelDesign { try_files $uri @spa; }
# 官网线路目录。这条不是前端路由;落到下方 SPA 会返回 index.html,浏览器看不到 JSON。
# 仅这一条转到对应环境的 Admin API(test → api.test.ideship.com,其余 → api.ideship.com)。
location = /channel/sales-product/portal/catalog {
set $oms_api_upstream api.ideship.com;
if ($host ~* "(^test\.ideship\.com$|\.test\.ideship\.com$)") {
set $oms_api_upstream api.test.ideship.com;
}
resolver 1.1.1.1 8.8.8.8 ipv6=off valid=300s;
resolver_timeout 5s;
proxy_http_version 1.1;
proxy_ssl_server_name on;
proxy_set_header Host $oms_api_upstream;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://$oms_api_upstream/admin/channel/sales-product/portal/catalog$is_args$args;
proxy_connect_timeout 10s;
proxy_read_timeout 30s;
}
# 营销前端路由(^~ 须比下方 /marketing/ API 正则代理更优先)
location ^~ /marketing/memberLevel { try_files $uri @spa; }
location ^~ /marketing/pointsRule { try_files $uri @spa; }
location ^~ /marketing/pointsFlow { try_files $uri @spa; }
location ^~ /marketing/couponTemplate { try_files $uri @spa; }
location ^~ /marketing/couponGrant { try_files $uri @spa; }
location ^~ /marketing/commissionRule { try_files $uri @spa; }
location ^~ /marketing/commissionDetail { try_files $uri @spa; }
location ^~ /marketing/commissionWithdraw { try_files $uri @spa; }
location ^~ /marketing/referralTree { try_files $uri @spa; }
# 面单/截图同源代理:/__cos__/<host>/<path> → http://<host>/<path>
# cos.ideship.com 自定义域名 https 证书不可用,上游走 http;避免浏览器直打 CORS / 混合内容
location ~ ^/__cos__/([^/]+)(/.*)$ {
set $cos_host $1;
set $cos_uri $2;
resolver 1.1.1.1 8.8.8.8 ipv6=off valid=300s;
resolver_timeout 5s;
proxy_http_version 1.1;
proxy_set_header Host $cos_host;
proxy_set_header Authorization "";
proxy_set_header Cookie "";
proxy_set_header X-Real-IP "";
proxy_pass http://$cos_host$cos_uri$is_args$args;
proxy_connect_timeout 10s;
proxy_read_timeout 120s;
proxy_buffering off;
}
# 系统管理前端路由(^~ 须比下方 /system/ API 正则代理更优先)
location = /system/dict { try_files $uri @spa; }
location = /system/warehouseAddress { try_files $uri @spa; }
location = /system/announcement { try_files $uri @spa; }
location ^~ /system/users { try_files $uri @spa; }
location ^~ /system/roles { try_files $uri @spa; }
location ^~ /system/menus { try_files $uri @spa; }
location ^~ /system/organizations { try_files $uri @spa; }
location ^~ /system/batchEmail { try_files $uri @spa; }
location ^~ /system/otherConfig { try_files $uri @spa; }
location ^~ /system/aiAssistant { try_files $uri @spa; }
location ^~ /system/aiSkills { try_files $uri @spa; }
location ^~ /system/mcpTools { try_files $uri @spa; }
location ^~ /system/dataPerm/ { try_files $uri @spa; }
# SPA 回退:try_files $uri @spa 统一带 no-cache,避免部署后浏览器缓存旧 index.html
location @spa {
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
try_files /index.html =404;
}
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
try_files /index.html =404;
}
# 微信 JS 安全域名校验:原样返回 txt,禁止 SPA 回落 index.html
location ~* ^/MP_verify_[A-Za-z0-9]+\.txt$ {
default_type text/plain;
charset off;
add_header Cache-Control "no-store";
try_files $uri =404;
}
location ~* \.(?:js|css)$ {
try_files $uri =404;
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
location / {
try_files $uri @spa;
}
}