# Setup Multisite Configuration with Let's Encrypt and no Reverse Proxy

**URL:** https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285
**Category:** Sysadmins
**Tags:** how-to, domains
**Created:** [January 6, 2021, 4:52pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285 "2021-01-06T16:52:21Z")
**Posts on this page:** 1
**Showing post:** 1

<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: [January 6, 2021, 4:52pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/1 "2021-01-06T16:52:21Z")

</div>

### These instructions should be considered _beta_ and for those familiar with a standard setup

But right now (2023.02.11) these instructions do not work!! (See [Set up Let’s Encrypt with multiple domains / redirects](https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685) for how to update the letsencrypt setting to add the `fullpath` part. I’ll update this to reflect those changes Real Soon Now.)

I developed this howto a couple weeks ago but need someone to test and see if this works for someone else. Please reply if you try and let me know whether it works and if anything is unclear.

### And on with the show. . .

This howto documents broadly how to set up a multisite setup with 2 additional hosts (3 total).

It assumes that you have a working [Discourse official Standard Installation](https://meta.discourse.org/t/discourse-official-standard-installation/142537) or 2-container installation ([Move from standalone container to separate web and data containers](https://meta.discourse.org/t/how-to-move-from-standalone-container-to-separate-web-and-data-containers/29413)).

### Domain name for primary site

### subdomain for the 2nd site

### Suddomain for the 3rd site

### Database password (same as `DISCOURSE_DB_PASSWORD`) or `discourse` in `app.yml`

For the sake of simplicity, this is for a main site called =domain=, with two additional sites =two=.=domain= and =three=.=domain=. You can use whatever names you want, but for the sake of this template, not having a different `short name` (for the database name and title for the sub-forum) and `full hostname` is a bit easier.

### add in `hooks` after the plugins in `app.yml` or `web_only.yml`

```plaintext
  before_bundle_exec:
    - file:
        path: $home/config/multisite.yml
        contents: |
         =two=:
           adapter: postgresql
           database: =two=
           pool: 25
           timeout: 5000
           host: data
           password: NThmZTNjZjZhOTczNmVj
           host_names:
             - =two=.=domain=
         =three=:
           adapter: postgresql
           database: =three=
           pool: 25
           timeout: 5000
           host: data
           password: NThmZTNjZjZhOTczNmVj
           host_names:
             - =three=.=domain=

  after_db_migrate:
    - exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate

  after_ssl:
   # tell letsencrypt what additional certs to get
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-d =domain= /
        to: "-d =domain= -d =two=.=domain= -d =three=.=domain="
        global: true
   # do not redirect all hosts back to the main domain name
    - replace:
        filename: "/etc/nginx/conf.d/discourse.conf"
        from: /if \(\$http_host[^\}]*\}/m
        to: ""

```

### Add to the `after_postgres` section in `app.yml` or `data.yml`

```plaintext
  - exec: sudo -u postgres createdb =two= || exit 0
    - exec:
        stdin: |
          grant all privileges on database =two= to discourse;
        cmd: sudo -u postgres psql =two=
        raise_on_fail: false

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

```

After that,

```plaintext
./launcher rebuild app

```

or

```plaintext
./launcher rebuild data
./launcher rebuild web_only

```

---

_[View the full topic](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285)._
