# 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:** 5
**Page:** 2

<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: [May 8, 2025, 2:37pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/21 "2025-05-08T14:37:18Z")

</div>

You likely need to change just the part having to do with the certificates.

Oh. Wait.

> [@manuel](#):
>
> since updating to 3.5.0.beta5-dev I’m now redirected to the primary site whenever I enter a subdomain.

It sounds like recent changes to the way that the NGINX configuration is managed that this bit is now in a different file:

```plaintext
   # 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: ""

```

Yes. Here’s the new place:

> <https://github.com/discourse/discourse_docker/blob/7b042d6157555c886e1cdcf77e8cb67c56ff8333/templates/web.ssl.template.yml#L33>

I **think** that changing that filename to `/etc/nginx/conf.d/outlets/server/20-https.conf` will solve the redirect problem. You’ll also need to make the changes about how the certificate is requested, though if it’s working, I guess you might not need to change it.

---

<div class="post-metadata">

### Author: ![manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/manuel/32/468169_2.png) [@manuel](https://meta.discourse.org/u/manuel)
#### Post date: [May 8, 2025, 5:13pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/22 "2025-05-08T17:13:54Z")

</div>

Thanks @pfaffman! Can’t get it working so far. Though I probably just ran into the Certificate limit as well, re-building with changes to the config file…

Gonna study the proxy stuff now 😭

---

<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: [May 8, 2025, 5:23pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/23 "2025-05-08T17:23:43Z")

</div>

> [@manuel](#):
>
> Though I probably just ran into the Certificate limit as well

If you did, you can just add another subdomain to the list (and the DNS record) and you’ll start a new rate limit.

---

<div class="post-metadata">

### Author: ![manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/manuel/32/468169_2.png) [@manuel](https://meta.discourse.org/u/manuel)
#### Post date: [May 8, 2025, 8:26pm UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/24 "2025-05-08T20:26:39Z")

</div>

Maybe I was just duped again by the browser cache 😵‍💫 In any case, I switched that server to the default multisite setup, with caddy as reverse proxy. In the end it’s also straightforward and one thing I actually like is that the certificates are for each domain then (and not all domains shared on one certificate).

Have another server to update, I’ll try the adjustments another time with that one to see what’s necessary..

Thanks again!

---

<div class="post-metadata">

### Author: ![kcahtoor](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@kcahtoor](https://meta.discourse.org/u/kcahtoor)
#### Post date: [August 27, 2026, 11:12am UTC](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285/25 "2026-08-27T11:12:24Z")

</div>

I think it better to use for loop for databases. It is little bit cleaner.

```yaml
hooks:
  after_postgres:
    - exec: |
        for db in two_db thirdsite_db; do
          sudo -u postgres createdb "$db" || true
          sudo -u postgres psql "$db" -c "grant all privileges on database $db to discourse;"
          sudo -u postgres psql "$db" -c "alter schema public owner to discourse;"
          sudo -u postgres psql "$db" -c "create extension if not exists hstore;"
          sudo -u postgres psql "$db" -c "create extension if not exists pg_trgm;"
        done

```

[Previous page](https://meta.discourse.org/t/setup-multisite-configuration-with-lets-encrypt-and-no-reverse-proxy/175285.md?page=1)
