WireGuard + Nginx 中转架构实战(五)Discourse 中转发布与 HTTPS 正确姿势

一、Discourse 的核心原则

  • :cross_mark: 不支持子路径
  • :white_check_mark: 必须子域名或根域名
  • :cross_mark: 不建议 Discourse 自己跑 HTTPS

二、源站 Discourse 端口绑定

编辑:

/var/discourse/containers/app.yml
ports:
  - "10.100.0.2:8082:80"

重建:

./launcher rebuild app

三、中转机 Nginx 配置

server {
    listen 443 ssl http2;
    server_name noth.me;

    location / {
        proxy_pass http://10.100.0.2:8082;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
    }
}

四、Discourse 后台设置

  • force_https = true
  • DISCOURSE_HOSTNAME = noth.me

五、常见 502 原因

原因 说明
容器未启动完成 Discourse 启动慢
端口未映射 app.yml 写错
中转太快访问 等 2~3 分钟

六、正确状态验证

curl -I http://10.100.0.2:8082

返回 200 / 302 即正常。


结语

到这里,你已经拥有一套:

  • 源站不可达
  • HTTPS 统一
  • Docker / Discourse 稳定运行
  • 可长期维护的中转架构