仅通过 HTTP 安装 Discourse(无 HTTPS)

我尝试在我的系统上安装 Discourse,但一直未能成功。

我在主机上运行着 Nginx 服务器,而 Discourse 则运行在该主机上的一个专用虚拟机中。Nginx 服务器负责处理所有 SSL 以及所有 HTTP 到 HTTPS 的重定向。我希望在 Nginx 和 Discourse 安装之间使用纯 HTTP 通信,但不知道如何禁用 Discourse 使用 SSL。

在配置了 SSL 的情况下,Discourse 会从我发起的 HTTP 请求开始,陷入无限的重定向循环,不断跳转到 HTTPS。

以下是我的 Nginx 配置片段:

    server {
      listen 443 ssl;
      listen [::]:443 ssl;

      server_name forum.example.com;

      # SSL 配置 ...
            ssl_certificate         /etc/nginx/certificates/cloudflare-example.com.pem;
            ssl_certificate_key     /etc/nginx/certificates/cloudflare-example.com.key;

      # 反向代理到 Discourse:
      location / {
        proxy_pass http://192.168.1.123:80/;
        proxy_http_version 1.1;
        proxy_set_header Host $http_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;
        proxy_read_timeout 120;
      }
    }

我曾尝试在 app.yml 中注释掉以下行:

#  - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"

然后使用 ./launcher rebuild app 重新构建,但 HTTP 服务器无法启动。

是否有针对此类设置的说明文档?或者我是否必须在 Nginx 和 Discourse 之间配置 SSL?

2 个赞

我猜这是因为你的 nginx 正在监听与应用程序相同的 80 端口(也许不是,我读得太快了,没注意到问题中的虚拟机部分 :sweat_smile:),使用 web.socketed 模板应该能解决这个问题(同时启用 https)。

4 个赞