# 这种配置是否能成功创建第二个Discourse实例（带代理）？

**URL:** https://meta.discourse.org/t/will-this-configuration-successfully-create-a-second-discourse-instance-with-proxy/326468
**Category:** Support
**Tags:** multisite
**Created:** [2024年九月14日 03:28 UTC](https://meta.discourse.org/t/will-this-configuration-successfully-create-a-second-discourse-instance-with-proxy/326468 "2024-09-14T03:28:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![joo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/joo/32/334852_2.png) [@joo](https://meta.discourse.org/u/joo)
#### Post date: [2024年九月14日 03:28 UTC](https://meta.discourse.org/t/will-this-configuration-successfully-create-a-second-discourse-instance-with-proxy/326468/1 "2024-09-14T03:28:37Z")

</div>

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

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

### 配置 (`app1.yml`)：

```plaintext
## 这是独立的 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"

```

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

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [2024年九月14日 06:22 UTC](https://meta.discourse.org/t/will-this-configuration-successfully-create-a-second-discourse-instance-with-proxy/326468/2 "2024-09-14T06:22:40Z")

</div>

> [@joo](#):
>
> ```plaintext
> - "templates/web.ssl.template.yml"
> - "templates/web.letsencrypt.ssl.template.yml"
> 
> ```

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2024年九月14日 10:03 UTC](https://meta.discourse.org/t/will-this-configuration-successfully-create-a-second-discourse-instance-with-proxy/326468/3 "2024-09-14T10:03:06Z")

</div>

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

[使用 Docker 进行多站点配置](https://meta.discourse.org/t/multisite-configuration-with-docker/14084)

[使用 Let’s Encrypt 和无反向代理设置多站点配置](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285)
