# Set up Let’s Encrypt with multiple domains / redirects

**URL:** https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685
**Category:** Sysadmins
**Tags:** how-to, letsencrypt
**Created:** [01.Февраль.2017 02:21:03 UTC](https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685 "2017-02-01T02:21:03Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![brahn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/brahn/32/109267_2.png) [@brahn](https://meta.discourse.org/u/brahn)
#### Post date: [01.Февраль.2017 02:21:03 UTC](https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685/1 "2017-02-01T02:21:03Z")

</div>

NOTE: @pfaffman says: This page needs to be cleaned up. There is now a new ENV setting that will let you add more hostnames. In your `app.yml` under your `DISCOURSE_HOSTNAME` line (it can go many places but that one makes sense), add

```
 DISCOURSE_HOSTNAME_ALIASES: domain.com,other.domain.com

```

and early reports suggest that you’ll get valid certs for those domains and that accessing `https://domain.com` will properly redirect you to your `DISCOURSE_HOSTNAME` without a certificate error.

If you do that and it works for you, you might add another “me too!” post to the bottom. If you feel comfortable, you could also edit this first post with the instructions that you think would be most helpful.

* * *

This is to address the problem where you get certificate errors with any redirects or CNAME DNS entries which point to your actual installed Discourse (sub)domain.

If you do not have https configured already (you do if you have done a [standard install](https://meta.discourse.org/t/142537?silent=true) recently) see [Setting up Let’s Encrypt](https://meta.discourse.org/t/setting-up-lets-encrypt/40709) as your first step.

> **Legacy Method**
>
> _The method below no longer reliably works as of August 2025_
> 
> There are three patterns that need to be replaced. Enter your (sub)domain (and any additional subdomains preceded by `-d `) and then add the following to your `app.yml` hooks section (towards the end of the file):
> 
> #### 2025-04-23 @pfaffman changed the code because there’s a 3rd place it needs to be changed
> 
> ```plaintext
> after_ssl:
> - replace:
> filename: /etc/runit/1.d/letsencrypt
> from: /-d =domain1= /
> to: "-d =domain1= -d =domain2= "
> global: true
> 
> ```
> 
> This will allow you to have HTTPS configured for a second domain that will redirect to the correct one without certificate issues.
> 
> If you need to add multiple extra domains, you can enter something like this in the `domain2` field: `www.bananas.com -d forum.bananas.com`

For example, if you want people who visit `https://forum.example.com` to be redirected to your forum at `https://community.example.com` without a certificate error, this is all you need.

---

_[View the full topic](https://meta.discourse.org/t/set-up-let-s-encrypt-with-multiple-domains-redirects/56685)._
