# Ghost Discourse 集成

**URL:** https://meta.discourse.org/t/ghost-discourse-integration/192220
**Category:** Support
**Created:** [2021年五月31日 22:46 UTC](https://meta.discourse.org/t/ghost-discourse-integration/192220 "2021-05-31T22:46:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Craigs](https://avatars.discourse-cdn.com/v4/letter/c/73ab20/32.png) [@Craigs](https://meta.discourse.org/u/Craigs)
#### Post date: [2021年五月31日 22:46 UTC](https://meta.discourse.org/t/ghost-discourse-integration/192220/1 "2021-05-31T22:46:32Z")

</div>

我正在努力解决 Ghost 与 Discourse 之间的集成问题。

Discourse 版本：2.8.0.beta1，运行在 Ubuntu 上的 Docker 环境中（未使用 nginx）。

我在一台独立系统上使用 Traefik，该系统位于单个 IP 路由器之后，处于 NAT 家庭局域网内。Traefik 支持 HTTP/HTTPS 路由。

Traefik 配置使用的是 `traefik_dynamic.toml` 文件，而不是 Docker 标签。没有共享的 Docker 网络。（如果有人对 Traefik 配置感兴趣，请私信我——它作为反向代理运行得相当不错）。

Ghost 也是最新版本（4.6.4），运行在另一台主机上（两台主机均为 Ubuntu 虚拟机，版本为 “20.04.2 LTS (Focal Fossa)”，运行在 Proxmox 上）。

我已按照 Ghost 文档网站和 Discourse 论坛上提供的各种教程页面进行操作。

Firefox 网页开发者工具显示，页面返回了以下源代码：

```plaintext
<div class="comment container small">

<div class="discourse-comments"></div>
    <script type="text/javascript">
     if (window.location.pathname.indexOf('/p/') < 0) {
      DiscourseEmbed = { discourseUrl: 'https://discourse.mydomain/', discourseEmbedUrl: 'https://ghost.mydomain/testing-new-stuff/' };

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
  })();
}
</script>
</div>

```

但没有实际评论返回。我可以看到我的 Discourse 主机返回了 `embed.js`，但页面上什么都没有。（抱歉，我不是网页开发人员）。

看来脚本确实已加载并返回了空内容。

这是一个新安装的 Discourse，仍处于训练模式（引导模式）。因此，目前几乎没有主题。

`app.yml` 文件附在后面。

我相信嵌入主机设置是正确的，使用了 Discourse 管理员用户作为创建主题的用户名，路径白名单目前为空。  
我创建了一个名为“testing”的分类，并将其添加到“发布到分类”中。

此外，我在 `app.yml` 中添加了 `DISCOURSE_ENABLE_CORS: true`，因为这可能会有所帮助。我将代理以及 `http://ghost.mydomain` 和 `http://ghost.mydomain` 添加到了 CORS 源中。

有人能建议如何调试这个问题吗？

```plaintext
app.yml:
#
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## 如果希望添加 Lets Encrypt (https)，请取消注释以下两行
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口？
## 如果您希望 Discourse 与 Apache 或 nginx 等其他 Web 服务器共享端口，
## 请参阅 https://meta.discourse.org/t/17247 获取详细信息
expose:
  - "8081:80" # http
    # - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最大 25%。
  ## 将根据检测到的 RAM 由引导程序自动设置，您也可以覆盖
  db_shared_buffers: "2048MB"

  ## 可以提高排序性能，但会增加每个连接的内存使用量
  #db_work_mem: "40MB"

  ## 此容器应使用哪个 Git 修订版？（默认：tests-passed）
  #version: tests-passed

env:
 LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  DISCOURSE_ENABLE_CORS: true

  ## 支持多少并发 Web 请求？取决于内存和 CPU 核心数。
  ## 将根据检测到的 CPU 由引导程序自动设置，您也可以覆盖
  UNICORN_WORKERS: 2

  ## TODO: 此 Discourse 实例将响应的域名
  ## 必需项。Discourse 无法仅使用 IP 地址运行。
  DISCOURSE_HOSTNAME: mydiscoursehost.mydomain

  ## 如果希望容器以与上述相同的主机名（-h 选项）启动，请取消注释
  ## （默认值为 "$hostname-$config"）
  #DOCKER_USE_HOSTNAME: true

  ## TODO: 初始注册时将成为管理员和开发人员的逗号分隔电子邮件列表
  ## 示例：'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'myemailaddress@mydomain'

  ## TODO: 用于验证新账户和发送通知的 SMTP 邮件服务器
  # SMTP 地址、用户名和密码是必需的
  # 警告：SMTP 密码中的字符 '#' 可能导致问题！
  DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: postmaster@mydomain
  DISCOURSE_SMTP_PASSWORD: "mypostmasterpassword7"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true # （可选，默认为 true）
  DISCOURSE_SMTP_DOMAIN: mydomain
  DISCOURSE_NOTIFICATION_EMAIL: noreply@mydomain

  ## 如果已添加 Lets Encrypt 模板，请取消注释以下行以获取免费 SSL 证书
  # LETSENCRYPT_ACCOUNT_EMAIL: notused

  ## 此 Discourse 实例的 HTTP 或 HTTPS CDN 地址（配置为拉取）
  ## 详见 https://meta.discourse.org/t/14857
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com
 
  ## MaxMind 地理位置 IP 查询的授权密钥
  ## 详见 https://meta.discourse.org/t/-/137387/23
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

## Docker 容器是无状态的；所有数据都存储在 /shared 中
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## 插件请放在此处
## 详见 https://meta.discourse.org/t/19157
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## 构建后运行的任何自定义命令
run:
  - exec: echo "Beginning of custom commands"
  ## 如果您想为首次注册设置“发件人”电子邮件地址，请取消注释并修改：
  ## 收到首次注册邮件后，请重新注释该行。该行只需运行一次。
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

```
