From fc51641700bfcf9571c8aac6390d65ac80eb3ddf Mon Sep 17 00:00:00 2001 From: Zhengen TANG Date: Fri, 11 Sep 2026 16:34:30 +0800 Subject: [PATCH] =?UTF-8?q?Windows=E9=83=A8=E7=BD=B2:=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E7=BB=9F=E4=B8=80=E6=94=B9=E4=B8=BA8080?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/windows/install-nssm-services.ps1 | 2 +- deploy/windows/nginx-wagtailcms.conf | 6 +++--- deploy/windows/serve-backend.ps1 | 2 +- documents/Windows服务器部署指南.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deploy/windows/install-nssm-services.ps1 b/deploy/windows/install-nssm-services.ps1 index 8773293..a91db0d 100644 --- a/deploy/windows/install-nssm-services.ps1 +++ b/deploy/windows/install-nssm-services.ps1 @@ -56,7 +56,7 @@ function Install-NssmService { New-Item -ItemType Directory -Force -Path (Join-Path $RepoRoot "logs") | Out-Null New-Item -ItemType Directory -Force -Path (Join-Path $RepoRoot "frontend\logs") | Out-Null -# --- 后端:wagtailcms-backend(waitress WSGI,监听 127.0.0.1:8000) ------------- +# --- 后端:wagtailcms-backend(waitress WSGI,监听 127.0.0.1:8080) ------------- Install-NssmService ` -Name "wagtailcms-backend" ` -Application $Powershell ` diff --git a/deploy/windows/nginx-wagtailcms.conf b/deploy/windows/nginx-wagtailcms.conf index 30f156c..a58240c 100644 --- a/deploy/windows/nginx-wagtailcms.conf +++ b/deploy/windows/nginx-wagtailcms.conf @@ -1,6 +1,6 @@ # wagtailcms Windows Server 生产环境 Nginx 反向代理配置模板 # (Windows 版 nginx 不支持 Unix Domain Socket 反向代理到 gunicorn, -# 后端改用监听 127.0.0.1:8000 的 waitress,因此这里全部走 TCP 端口。) +# 后端改用监听 127.0.0.1:8080 的 waitress,因此这里全部走 TCP 端口。) # # 使用方法: # 1. 下载 nginx for Windows(http://nginx.org/en/download.html),解压到 C:\nginx @@ -10,7 +10,7 @@ # 3. 将下面的 example.com / cms.example.com 替换为真实域名 # 4. nginx.exe -t 测试配置,nginx.exe -s reload 重载 # -# 架构:浏览器 -> Nginx(TLS 终止) -> {Next.js:3000(页面渲染) | waitress:8000(/admin /api /static /media 等后端路径)} +# 架构:浏览器 -> Nginx(TLS 终止) -> {Next.js:3000(页面渲染) | waitress:8080(/admin /api /static /media 等后端路径)} # --------------------------------------------------------------------------- # 后端管理域名(Wagtail 管理后台 / API),对应 WAGTAILADMIN_BASE_URL @@ -34,7 +34,7 @@ server { } location / { - proxy_pass http://127.0.0.1:8000; + proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/deploy/windows/serve-backend.ps1 b/deploy/windows/serve-backend.ps1 index 3d8b183..fdf058c 100644 --- a/deploy/windows/serve-backend.ps1 +++ b/deploy/windows/serve-backend.ps1 @@ -18,4 +18,4 @@ if (-not (Test-Path $python)) { throw "找不到虚拟环境解释器:$python,请先创建虚拟环境并安装 requirements/production-windows.txt" } -& $python -m waitress --listen=127.0.0.1:8000 --threads=8 wagtailcms.wsgi:application +& $python -m waitress --listen=127.0.0.1:8080 --threads=8 wagtailcms.wsgi:application diff --git a/documents/Windows服务器部署指南.md b/documents/Windows服务器部署指南.md index 5b8b021..9253177 100644 --- a/documents/Windows服务器部署指南.md +++ b/documents/Windows服务器部署指南.md @@ -6,7 +6,7 @@ - [`deploy/windows/install-nssm-services.ps1`](../deploy/windows/install-nssm-services.ps1):用 NSSM 把前后端注册为 Windows 服务 - [`requirements/production-windows.txt`](../requirements/production-windows.txt):Windows 专用生产依赖(用 waitress 替代不支持 Windows 的 gunicorn) -架构:浏览器 → Nginx for Windows(TLS 终止)→ { Next.js(127.0.0.1:3000) | waitress(127.0.0.1:8000) }, +架构:浏览器 → Nginx for Windows(TLS 终止)→ { Next.js(127.0.0.1:3000) | waitress(127.0.0.1:8080) }, 两个进程均由 NSSM 注册为 Windows 服务,实现开机自启 + 崩溃自动重启。 ## 1. 服务器基础环境 @@ -124,7 +124,7 @@ Get-Service wagtailcms-* 服务日志分别写在 `C:\wagtailcms\logs\` 和 `C:\wagtailcms\frontend\logs\`(自动按 10MB 滚动)。 -> `serve-backend.ps1` 内部用 `waitress-serve` 监听 `127.0.0.1:8000`,`wagtailcms-frontend` +> `serve-backend.ps1` 内部用 `waitress-serve` 监听 `127.0.0.1:8080`,`wagtailcms-frontend` > 服务直接执行 `npm run start`(Next.js 默认监听 3000)。两者都设置了 > `Start=SERVICE_AUTO_START`(开机自启)+ `AppRestartDelay=5000`(崩溃 5 秒后自动重启)。 @@ -176,7 +176,7 @@ Windows 上常用方案: New-NetFirewallRule -DisplayName "HTTP" -Direction Inbound -LocalPort 80 -Protocol TCP -Action Allow New-NetFirewallRule -DisplayName "HTTPS" -Direction Inbound -LocalPort 443 -Protocol TCP -Action Allow ``` -云服务商控制台安全组同样放行 80/443;`8000`/`3000` 只监听 `127.0.0.1`,无需(也不应该)对公网开放。 +云服务商控制台安全组同样放行 80/443;`8080`/`3000` 只监听 `127.0.0.1`,无需(也不应该)对公网开放。 ## 12. 验证清单