From b0f2faabd090d08bf7d94826e8c3a3d33f14d2d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 11:35:26 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20cl?= =?UTF-8?q?arify=20Nginx=20escaping=20comment,=20search=20only=20sites-ava?= =?UTF-8?q?ilable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- .github/workflows/deploy-to-server.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-server.yml b/.github/workflows/deploy-to-server.yml index 500ffe3f..1208d6e6 100644 --- a/.github/workflows/deploy-to-server.yml +++ b/.github/workflows/deploy-to-server.yml @@ -281,6 +281,8 @@ jobs: if ! grep -rq 'location /api/' /etc/nginx/sites-available/ /etc/nginx/conf.d/ /etc/nginx/snippets/ 2>/dev/null; then echo '🔄 添加 API + WebSocket 反向代理...' sudo mkdir -p /etc/nginx/snippets + # 注意:\$ 在本地 shell 中转义为 $,远程 shell 的单引号保护不再展开, + # 最终写入文件的 Nginx 变量为 $host、$http_upgrade 等 printf '%s\n' \ '# guanghulab 反向代理(由 CD 工作流自动生成)' \ '' \ @@ -308,8 +310,8 @@ jobs: '}' \ | sudo tee /etc/nginx/snippets/guanghulab-proxy.conf > /dev/null - # 在 server 块中加入 include 指令 - NGINX_MAIN=\$(grep -rl 'server_name' /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ 2>/dev/null | head -1) + # 在 server 块中加入 include 指令(仅搜索 sites-available 避免 symlink 重复) + NGINX_MAIN=\$(grep -rl 'server_name' /etc/nginx/sites-available/ 2>/dev/null | head -1) if [ -z \"\$NGINX_MAIN\" ]; then NGINX_MAIN='/etc/nginx/sites-available/default' fi