这种配置是否能成功创建第二个Discourse实例(带代理)?

我正在同一台服务器上设置第二个 Discourse 站点,并使用反向代理来管理流量。我对技术方面不太熟悉,因此我正在寻求一些指导,以确保一切都配置正确。下面是我为新容器使用的 app1.yml 文件。

我想知道这个设置是否能成功地让我并行运行两个 Discourse 实例。

配置 (app1.yml):

## 这是独立的 Discourse Docker 容器模板
##
## 更改此文件后,您必须重建
## /var/discourse/launcher rebuild app1
##
## 编辑时请*非常*小心!
## YAML 文件对空格或对齐错误非常敏感!
## 如有需要,请访问 http://www.yamllint.com/ 来验证此文件

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"
image: discourse/discourse:latest

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

params:
  db_default_text_search_config: "pg_catalog.english"
  db_shared_buffers: "2048MB"
  upload_size: 100m

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: zh_CN
  DISCOURSE_FORCE_HTTPS: 'true'
  UNICORN_WORKERS: 8
  DISCOURSE_HOSTNAME: xxxx.com
  DISCOURSE_DEVELOPER_EMAILS: 'youremail@xxxx.com'
  DISCOURSE_SMTP_ADDRESS: xxxxx
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: your_smtp_username
  DISCOURSE_SMTP_PASSWORD: "your_smtp_password"
  DISCOURSE_NOTIFICATION_EMAIL: no-reply@xxxx.com
  LETSENCRYPT_ACCOUNT_EMAIL: me@example.com
  DISCOURSE_MAXMIND_LICENSE_KEY: xxxxxxx

volumes:
  - volume:
      host: /var/discourse/shared/app1
      guest: /shared
  - volume:
      host: /var/discourse/shared/app1/log/var-log
      guest: /var/log

hooks:
  after_postgres:
    - exec: sudo -u postgres createdb discourse_app1 || exit 0
    - exec:
         stdin: |
           grant all privileges on database discourse_app1 to discourse;
         cmd: sudo -u postgres psql discourse_app1
    - exec: /bin/bash -c 'sudo -u postgres psql discourse_app1 <<< "alter schema public owner to discourse;"'
    - exec: /bin/bash -c 'sudo -u postgres psql discourse_app1 <<< "create extension if not exists hstore;"'
    - exec: /bin/bash -c 'sudo -u postgres psql discourse_app1 <<< "create extension if not exists pg_trgm;"'

run:
  - exec: echo "Beginning of custom commands"
  - exec: echo "End of custom commands"

由于我对编码不太熟悉,因此非常感谢您能提供任何建议或改进此设置!

如果您正在使用反向代理,则需要注释掉这两行。

另外,最好使用两个容器的设置来只拥有一个数据库,但你需要两个 Redis。你也可以考虑多站点。

使用 Docker 进行多站点配置

使用 Let’s Encrypt 和无反向代理设置多站点配置

1 个赞