Will This Configuration Successfully Create a Second Discourse Instance (with Proxy)?

I’m setting up a second Discourse site on the same server, and I’m using a reverse proxy to manage traffic. I’m not very experienced with the technical side of things, so I’m looking for some guidance to make sure everything is correctly configured. Below is the app1.yml file I’ve used for the new container.

I want to know if this setup will successfully allow me to run two Discourse instances in parallel.

Configuration (app1.yml):

## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app1
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

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

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  #- "80"   # internal HTTP port
  #- "443"  # internal HTTPS port

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"

Since I’m not very familiar with coding, any advice or improvements to this setup would be greatly appreciated!

You need to comment these two lines if you’re using a reverse proxy.

Also, it’s probably better to use a two container setup to have just one database, but you need two redis. You could also consider multisite.

Multisite configuration with Docker

Setup Multisite Configuration with Let’s Encrypt and no Reverse Proxy

1 Like