部署配置:新增 Windows Server 裸机部署流程

- requirements/production-windows.txt:Windows 专用生产依赖,用 waitress 替代
  不支持 Windows 的 gunicorn
- deploy/windows/serve-backend.ps1:waitress WSGI 启动脚本
- deploy/windows/install-nssm-services.ps1:用 NSSM 将前后端注册为 Windows 服务
- deploy/windows/nginx-wagtailcms.conf:nginx for Windows 反向代理模板(TCP 端口,
  不用 unix socket)
- documents/Windows服务器部署指南.md:完整部署步骤文档,并说明与 Linux 裸机
  部署(systemd/gunicorn/unix socket/Redis)的差异点
This commit is contained in:
2026-09-11 09:39:30 +08:00
parent 777f5367da
commit 1686794ad7
5 changed files with 384 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
# wagtailcms Windows Server 生产环境 Nginx 反向代理配置模板
# (Windows 版 nginx 不支持 Unix Domain Socket 反向代理到 gunicorn,
# 后端改用监听 127.0.0.1:8000 的 waitress,因此这里全部走 TCP 端口。)
#
# 使用方法:
# 1. 下载 nginx for Windows(http://nginx.org/en/download.html),解压到 C:\nginx
# 2. 将本文件内容追加/替换到 C:\nginx\conf\nginx.conf 的 http{} 块内
# (或用 include 语法:在 http{} 块中加一行 include wagtailcms.conf;,
# 并把本文件放到 C:\nginx\conf\wagtailcms.conf)
# 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 等后端路径)}
# ---------------------------------------------------------------------------
# 后端管理域名(Wagtail 管理后台 / API),对应 WAGTAILADMIN_BASE_URL
# ---------------------------------------------------------------------------
server {
listen 80;
server_name cms.example.com;
client_max_body_size 20m;
location /static/ {
alias C:/wagtailcms/staticfiles/;
access_log off;
expires 30d;
}
location /media/ {
alias C:/wagtailcms/media/;
access_log off;
expires 7d;
}
location / {
proxy_pass http://127.0.0.1:8000;
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;
}
}
# ---------------------------------------------------------------------------
# 前端站点域名(Next.js 页面),公众访问入口
# ---------------------------------------------------------------------------
server {
listen 80;
server_name www.example.com example.com;
client_max_body_size 20m;
location /_next/static/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
expires 30d;
access_log off;
}
location / {
proxy_pass http://127.0.0.1:3000;
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;
}
}
# 提示:申请到证书后(win-acme / 阿里云 SSL 证书服务下载 Nginx 格式证书),
# 手动加 `listen 443 ssl;` + `ssl_certificate`/`ssl_certificate_key` 指令,
# 并在 80 端口 server 块中加 `return 301 https://$host$request_uri;` 强制跳转。