feat: 生产部署接入 TAC 验证码(JWT_SECRET + WireGuard upstream + 反代健康检查)
This commit is contained in:
1 parent
7182e46ee4
commit
c05339e21c
3 files changed
+25
-4
No files matched your search
@@ -42,12 +42,18 @@ jobs:
|
||||
docker stop perler-lab-server perler-lab-frontend 2>/dev/null || true
|
||||
docker rm perler-lab-server perler-lab-frontend 2>/dev/null || true
|
||||
docker network create perler-net 2>/dev/null || true
|
||||
# TAC 人机验证:prod2 公网到 prod1:18200 被安全组拦截,走 WireGuard 内网(已实测容器级连通)
|
||||
docker run -d --name perler-lab-server \
|
||||
--restart unless-stopped \
|
||||
--network perler-net \
|
||||
--network-alias server \
|
||||
-e PORT=8788 \
|
||||
-e DATABASE_URL='postgres://pgsql:XGYnJPysCNJsLeea@postgres:5432/perler_lab' \
|
||||
-e JWT_SECRET='ab0538194ce36bdb85afc22e608e5b548bc5717d4e5f7cda917701ef2c53bca6' \
|
||||
-e TAC_ENABLED="true" \
|
||||
-e TAC_API_BASE="http://10.9.0.2:18200" \
|
||||
-e TAC_SITE_KEY="6796bad8-4369-492f-a4d7-643a93bb07f3" \
|
||||
-e TAC_SECRET_KEY="dae2c135-4e61-4249-a5bb-a15081b1a2b6" \
|
||||
-p 8788:8788 \
|
||||
perler-lab-server:latest
|
||||
# 后端需连 prod 主库(middleware-postgres),接入 middleware 网络以解析 postgres 别名
|
||||
@@ -55,6 +61,7 @@ jobs:
|
||||
docker run -d --name perler-lab-frontend \
|
||||
--restart unless-stopped \
|
||||
--network perler-net \
|
||||
-e CAPTCHA_UPSTREAM="10.9.0.2:18200" \
|
||||
-p 8080:80 \
|
||||
perler-lab-frontend:latest
|
||||
echo '容器已启动,等待健康检查...'
|
||||
@@ -63,6 +70,10 @@ jobs:
|
||||
curl -sf http://localhost:8788/health && echo '后端 OK'
|
||||
echo '--- 前端健康检查 ---'
|
||||
curl -s -o /dev/null -w '前端 HTTP %{http_code}\n' http://localhost:8080/ || echo '前端未就绪'
|
||||
echo '--- 验证码反代检查(前端 /tac/api → prod1:18200) ---'
|
||||
TAC_CODE=$(curl -s -m 10 -o /dev/null -w '%{http_code}' -X POST http://localhost:8080/tac/api/challenge/generate -H 'X-Site-Key: 6796bad8-4369-492f-a4d7-643a93bb07f3' -H 'Content-Type: application/json' -d '{"captchaType":"SLIDER"}' || true)
|
||||
if [ "$TAC_CODE" != "200" ]; then echo "验证码反代检查失败 (HTTP $TAC_CODE)"; exit 1; fi
|
||||
echo "验证码反代 OK (HTTP $TAC_CODE)"
|
||||
echo '? 生产部署完成'
|
||||
|
||||
# 版本已上生产,清理 test2 环境对应版本(新规则)
|
||||
|
||||
@@ -35,8 +35,13 @@ RUN npm run build
|
||||
# ── 第二阶段:Nginx 运行 ──
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
# 复制 nginx 配置
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# 验证码平台 upstream 默认值(公网 IP,测试环境/外部部署直接可用);
|
||||
# 生产 deploy-prod.yml 用 -e CAPTCHA_UPSTREAM=10.9.0.2:18200 覆盖为 WireGuard 内网
|
||||
ENV CAPTCHA_UPSTREAM=38.76.218.110:18200
|
||||
|
||||
# 以模板方式挂载:nginx 镜像入口启动时用 envsubst 渲染 ${CAPTCHA_UPSTREAM} 后
|
||||
# 生成 /etc/nginx/conf.d/default.conf(官方镜像 /docker-entrypoint.d/20-envsubst-on-templates.sh)
|
||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
||||
|
||||
# 复制构建产物(dist/ 含 index.html + assets/)到 nginx 根目录
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
@@ -17,8 +17,13 @@ upstream backend {
|
||||
}
|
||||
|
||||
upstream captcha-platform {
|
||||
# tianai-captcha 自托管平台(prod1),安全组仅放行本服务器 IP
|
||||
server 38.76.218.110:18200;
|
||||
# tianai-captcha 自托管平台(prod1)。
|
||||
# 值由环境变量 CAPTCHA_UPSTREAM 注入(Dockerfile 给默认值,生产 deploy-prod.yml
|
||||
# 覆盖为 WireGuard IP 10.9.0.2:18200——prod2 公网到 prod1:18200 被安全组拦截)。
|
||||
# 本文件作为 /etc/nginx/templates/default.conf.template 挂载,由 nginx 镜像入口的
|
||||
# envsubst 渲染;envsubst 只替换「已定义的环境变量」,$host/$remote_addr 等
|
||||
# nginx 内置变量不受影响。
|
||||
server ${CAPTCHA_UPSTREAM};
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
Reference in new issue
Block a user