Centminmod + discourse

你好。
我很想在我的 centminmod LEMP 堆栈 (https://centminmod.com/) 上试用 discourse 平台。

我已经成功安装了 Docker。

docker -v
Docker version 20.10.17, build 100c701

我遵循了安装指南 (discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub),做了一些小的调整——我没有云服务器。这是我的托管实例。

我也不得不手动编辑我的 /containers/app.yml

完成这些操作后,我通过 ./launcher rebuild app 重建应用程序时没有收到任何错误。

但是,我也无法连接到 docker 实例。它会跳转到我的虚拟主机的登陆页面。

我需要做什么才能将 nginx 配置反向代理到 docker?或者是否有人为在 centmindmod 上安装 discourse 编写了指南?

谢谢!

安迪

我想这可能最接近您正在寻找的内容 Run other websites on the same machine as Discourse

我已经成功安装了 Discourse。

安装 Docker - 此处不详述
安装 Discourse -

git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

在 /var/discource/containers 中配置 app.yaml

调整 app.yml 以移除端口 80+443

## 修改此文件后,您必须重建
## /var/discourse/launcher rebuild app
##
## 编辑时请*非常*小心!
## YAML 文件对空格或对齐错误非常非常敏感!
## 如有需要,请访问 http://www.yamllint.com/ 进行验证

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.socketed.template.yml"
  #- "templates/web.ratelimited.template.yml"

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

  #- "25654:80"   # http
  #- "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## 将 db_shared_buffers 设置为总内存的最多 25%。
  ## 将由 bootstrap 根据检测到的 RAM 自动设置,或者您可以覆盖它
  db_shared_buffers: "128MB"
 
  ## 可以提高排序性能,但会增加每个连接的内存使用量
  #db_work_mem: "40MB"
 
  ## 此容器应使用哪个 Git 版本? (默认值:tests-passed)
  #version: tests-passed

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

  ## 支持多少并发 Web 请求?取决于内存和 CPU 核心。
  ## 将由 bootstrap 根据检测到的 CPU 自动设置,或者您可以覆盖它
  UNICORN_WORKERS: 2

  ## TODO:此 Discourse 实例将响应的域名
  ## 考虑将其视为 Nginx 配置中的 server_name
  DISCOURSE_HOSTNAME: 'your.site.com'
 
  ## 如果您希望容器以与上面指定的相同主机名(-h 选项)启动(默认为“$hostname-$config”),请取消注释
  #DOCKER_USE_HOSTNAME: true

  ## TODO:将成为初始注册时管理员和开发人员的逗号分隔的电子邮件列表
  ## 例如 'user1@example.com,user2@example.com'
  ## 此电子邮件将是您首次登录 Discourse 实例时使用的电子邮件。
  DISCOURSE_DEVELOPER_EMAILS: 'email@your.com'

  ## TODO:用于验证新帐户和发送通知的 SMTP 邮件服务器
  DISCOURSE_SMTP_ADDRESS: smtp.your.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: email@your.com
  DISCOURSE_SMTP_PASSWORD: addpasswordhere  # 警告:密码中的字符 '#' 可能会导致问题!
  ## 如果这是一个 JSON 对象,则不会出现上述密码问题

  ## 此 Discourse 实例的 CDN 地址(配置为拉取)
  ## 有关详细信息,请参阅 https://meta.discourse.org/t/14857
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## 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 "开始执行自定义命令"
  ## 如果您想设置首次注册的“发件人”电子邮件地址,请取消注释并进行更改:
  ## 收到首次注册电子邮件后,请重新注释该行。它只需要运行一次。
  - exec: rails r "SiteSetting.notification_email='noreply@khophi.co'"
  - exec: echo "自定义命令结束"

查找 /usr/local/nginx/conf/conf.d
编辑相关配置

添加

proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;

到 location / {

将 include /usr/local/nginx/conf/503include-only.conf; 注释掉

另外

#include /usr/local/nginx/conf/pre-staticfiles-local-yourdomain.com.conf;
  #include /usr/local/nginx/conf/pre-staticfiles-global.conf;
  #include /usr/local/nginx/conf/staticfiles.conf;
  #include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
  #include /usr/local/nginx/conf/vts_server.conf;