Cloudflare Tunnels - Discourse 设置未识别主机名(端口不可访问)

我已经正确运行了 cloudflared 守护进程,并且已经用它做了很多事情(意味着隧道已正确安装在服务器上),但我无法让 Discourse 设置(./discourse-setup)识别我的 Discourse 实例的主机名。

  • 我将 biohacking.forum 用作我的实例的主机名。
  • 这是我的 biohacking.forum 的 Cloudflare Tunnel 配置:
  • 我也尝试将其设置为 HTTPS 作为服务类型
  • 我正在 Ubuntu 服务器上设置 Discourse,使用的是 LTS 版本。
  • 我按顺序运行了以下命令:
  1. sudo mkdir /var/discourse
  2. sudo git clone GitHub - discourse/discourse_docker: A Docker image for Discourse /var/discourse
  3. cd /var/discourse
  4. sudo ./discourse-setup
  5. 它会提示我输入主机名,我输入 biohacking.forum
  6. 显示以下消息:
Hostname for your Discourse? [discourse.example.com]: biohacking.forum

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname:  biohacking.forum.
WARNING: Connection to http://biohacking.forum (port 80) also fails.

This suggests that biohacking.forum resolves to some IP address that does not reach this
machine where you are installing discourse.

The first thing to do is confirm that biohacking.forum resolves to the IP address of this server.
You usually do this at the same place you purchased the domain.

If you are sure that the IP address resolves correctly, it could be a firewall issue.
A web search for "open ports YOUR CLOUD SERVICE" might help.

This tool is designed only for the most standard installations. If you cannot resolve
the issue above, you will need to edit containers/app.yml yourself and then type

./launcher rebuild app

我该如何让这一步奏效,如果您需要任何其他信息,请告诉我。谢谢!

嘿,你在运行 ./discourse-setup 之前,是否已经为“A”记录设置了灰色云(仅限 DNS)?

我没有使用标准的 A 记录,我使用的是 Cloudflare Tunnels。以下是一个在我的服务器上(使用 Cloudflare Tunnels)完美运行的服务示例及其相关配置:

Ghost CMS 是该服务:
端口:8085:2368(8085 是主机,2368 是服务)
主机名:joshuahabka.com
Cloudflare Tunnel 设置:

橙色的 Cloudflare 图标已开启,因为它使用了 Cloudflare Tunnels,但对于 Discourse,它应该报告为一个正常的访问端口。我已经部署了 40 多个服务并使其可在线访问,Discourse 是我遇到的第一个出现错误的。

如果您需要其他信息,请告诉我!

因此,对于 Discourse,我假设端口是:
443:443 (主机:服务),这就是为什么我像上面所示那样设置了我的原始 Cloudflare 隧道。

您好 @joshhabka :wave:
也许这个话题能帮到您,如果您还没看过的话:

4 个赞

您好 Lilly,上述指南对我无效,尽管我的 cloudflare 隧道配置是 http://localhost:80,但我仍然收到相同的错误,并且仍然卡在

starserver@Starserver:/var/discourse$ sudo ./discourse-setup
端口 80 和 443 可用
'samples/standalone.yml' -> 'containers/app.yml'
./discourse-setup: line 261: 4
scaling*                 2: 表达式语法错误(错误标记是“scaling*                 2”)

您的 Discourse 主机名? [discourse.example.com]: biohacking.forum

正在检查您的域名 . . .
警告:似乎无法通过主机名 biohacking.forum 访问计算机的端口 443。
警告:连接到 http://biohacking.forum(端口 80)也失败。

这表明 biohacking.forum 解析到的 IP 地址无法到达您正在安装 discourse 的这台机器。
首先要做的是确认 biohacking.forum 解析到此服务器的 IP 地址。
您通常在购买域名的同一地点进行此操作。

如果您确定 IP 地址解析正确,则可能是防火墙问题。
搜索“打开端口 YOUR CLOUD SERVICE”可能会有所帮助。

此工具仅适用于最标准的安装。如果您无法解决上述问题,则需要自己编辑 containers/app.yml,然后键入

./launcher rebuild app

关闭“始终使用 HTTPS”

将所有方案为“http”的请求重定向到“https”。这适用于到该区域的所有 http 请求。这会导致端口 80 成功,但 443 不成功。

启用将页面规则重定向到 HTTPS 也会导致 80 和 443 端口失败,但如果我不使用它,则 443 端口失败而 80 端口成功。

你没有遵循说明。

你不能使用 discourse-setup,除非用它来创建 yml 文件。

1 个赞

谢谢,我现在卡在这里了:

FAILED
--------------------
Pups::ExecError: /usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_SMTP_ADDRESS\"] == \"smtp.example.com\"; puts \"Aborting! Mail is not configured!\"; exit 1; end' failed with return #<Process::Status: pid 134 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"tag"=>"precompile", "cmd"=>["/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_SMTP_ADDRESS\"] == \"smtp.example.com\"; puts \"Aborting! Mail is not configured!\"; exit 1; end'", "/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_HOSTNAME\"] == \"discourse.example.com\"; puts \"Aborting! Domain is not configured!\"; exit 1; end'", "/usr/local/bin/ruby -e 'if (ENV[\"DISCOURSE_CDN_URL\"] || \"\")[0..1] == \"//\"; puts \"Aborting! CDN must have a protocol specified. Once fixed you should rebake your posts now to correct all posts.\"; exit 1; end'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

您需要编辑 yml 文件并输入 smtp 凭据。

已完成,现在一切正常。我会在 Cloudflare Tunnel 自安装帖子中添加一条说明,指出人们需要编辑 yaml 文档以添加他们的 smtp、主机名、电子邮件等。

谢谢!

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.