From cf14d8a6db542db4fe1444cf41fc278c5a044538 Mon Sep 17 00:00:00 2001 From: dxin Date: Wed, 31 Dec 2025 11:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=98=E7=BD=91=E6=B7=B7?= =?UTF-8?q?=E5=90=88SSR=E5=8A=A0=E8=BD=BD=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/lessie_official_web.conf | 84 +++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/nginx/lessie_official_web.conf b/nginx/lessie_official_web.conf index 7d25a53..58d60d1 100644 --- a/nginx/lessie_official_web.conf +++ b/nginx/lessie_official_web.conf @@ -1,6 +1,6 @@ upstream official_backend { - server 10.0.0.5:3000; # 机器A的内网地址 - server 10.0.0.15:3000; # 机器B的内网地址 + server 10.0.0.5:3000; + server 10.0.0.15:3000; } upstream new_official_backend { @@ -54,37 +54,58 @@ server { access_log /data/tengine/logs/lessie.ai.access.log official_log; error_log /data/tengine/logs/lessie.ai.error.log; - # 1. 新框架的业务页面逻辑 + # SSR 场景放大超时 + proxy_connect_timeout 300s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + + # 拦截 PHP / WordPress 扫描 + location ~* \.php$ { + return 444; + } + + # 新框架的业务页面逻辑 location ~ "^/([a-z]{2}(-[a-z]{2})?/)?(influencer-marketing|b2b-lead-generation|investor-scouting|recruiting|partnerships)" { proxy_pass http://new_official_backend; + proxy_http_version 1.1; proxy_set_header Host $host; 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; } - # 2. 静态资源分流 (核心逻辑) - location ~ ^/(_next/|__nuxt/|.*\.json) { - # 默认给老项目 (3000端口) - set $target_upstream http://official_backend; - - # 只有当来源页面 (Referer) 明确包含新项目的关键字时,才改发到 3003 - if ($http_referer ~* "(influencer-marketing|b2b-lead-generation|investor-scouting|recruiting|partnerships)") { - set $target_upstream http://new_official_backend; - } - - proxy_pass $target_upstream; + # Next.js 静态 & data + location ^~ /_next/ { + proxy_pass http://new_official_backend; + proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - # 反向代理到后端服务器渲染的nxut项目3000端口(老框架的完整页面) - location / { + # Nuxt 静态资源 + location ^~ /_nuxt/ { proxy_pass http://official_backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } + # Nuxt data / 其他 json + location ~ \.json$ { + proxy_pass http://official_backend; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + # 旧站(Nuxt SSR) + location / { + proxy_pass http://official_backend; + proxy_http_version 1.1; + proxy_set_header Host $host; + 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; + } + location /video/ { root /data/tengine/html/lessie_official; expires 30d; @@ -101,7 +122,6 @@ server { proxy_pass http://official_backend; proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; add_header Cache-Control "no-cache, no-store, must-revalidate" always; add_header Pragma "no-cache" always; @@ -116,9 +136,31 @@ server { add_header Expires 0 always; } - # 第三方邮件SendGrid平台调用 + # 第三方邮件件平台调国内email location /prod-api/webhook/ { proxy_pass http://129.204.158.54:4997/webhook/; + proxy_set_header Host 129.204.158.54; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_intercept_errors off; + proxy_buffering off; + proxy_cache off; + proxy_set_header Connection keep-alive; + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always; + + if ($request_method = OPTIONS ) { + return 204; + } + } + + # 第三方邮件SendGrid平台调用 + location /prod-api/webhook/us { + proxy_pass http://10.0.0.10:4997/webhook/us; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -139,8 +181,8 @@ server { } # 第三方支付平台调用 - location /payment/ / { - proxy_pass http://129.204.158.54:8090; + location /payment/ { + proxy_pass http://10.0.0.8:8090; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;