[fix]:[FL-196][nginx 动态 DNS 解析 + 部署流程中重启 nginx,防止容器重启后 502]

This commit is contained in:
chengkai3
2026-06-27 18:17:00 +08:00
parent 4cbd7262ae
commit fdbf8839c5
2 changed files with 28 additions and 3 deletions
+18
View File
@@ -230,3 +230,21 @@ jobs:
exit 1
fi
compose_run ps
- name: 重启 nginx 清 DNS 缓存
uses: appleboy/ssh-action@v1.2.0
env:
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH || vars.DEPLOY_PATH }}
with:
host: ${{ secrets.SERVER_HOST || vars.SERVER_HOST }}
username: ${{ secrets.SERVER_USER || vars.SERVER_USER }}
port: ${{ secrets.SERVER_PORT || vars.SERVER_PORT || 22 }}
timeout: 60s
command_timeout: 30s
key: ${{ secrets.SERVER_SSH_KEY }}
password: ${{ secrets.SERVER_PASSWORD }}
envs: DEPLOY_PATH
script: |
DEPLOY_DIR="${DEPLOY_PATH:-/opt/fquiz}"
cd "${DEPLOY_DIR}"
docker compose -p "$(awk -F= '/^COMPOSE_PROJECT_NAME=/{print $2; exit}' deploy/pro-deploy/.env | tr -d '[:space:]')" -f deploy/pro-deploy/compose.yml restart proxy
+10 -3
View File
@@ -4,8 +4,13 @@ server {
client_max_body_size 200m;
# Docker internal DNS resolver — forces nginx to re-resolve service names
# at runtime instead of caching IPs at startup (fixes 502 after container restart)
resolver 127.0.0.11 valid=10s;
location /api/v1/ws {
proxy_pass http://api:8000;
set $backend_api "http://api:8000";
proxy_pass $backend_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -18,7 +23,8 @@ server {
}
location /api/ {
proxy_pass http://api:8000;
set $backend_api "http://api:8000";
proxy_pass $backend_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@@ -29,7 +35,8 @@ server {
}
location / {
proxy_pass http://web:3000;
set $backend_web "http://web:3000";
proxy_pass $backend_web;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;