# Let's Encrypt and multisite (on 2 containers)

**URL:** https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962
**Category:** Support
**Created:** [10.Июль.2018 10:58:03 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962 "2018-07-10T10:58:03Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [10.Июль.2018 10:58:03 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/1 "2018-07-10T10:58:03Z")

</div>

Continuing the discussion from [Setting up Let’s Encrypt with Multiple Domains](https://meta.discourse.org/t/setting-up-let-s-encrypt-with-multiple-domains/56685/16):

Hi!  
I tried this [how to](https://meta.discourse.org/t/setting-up-let-s-encrypt-with-multiple-domains/56685) but nothing changed and `/etc/runit/1.d/letsencrypt` is not modified.  
I’ve 2 containers (data.yml) and web.yml and want to use multisite config.

Here the after\_ssl I used (from [Set up Let’s Encrypt with multiple domains / redirects - #15](https://meta.discourse.org/t/setting-up-let-s-encrypt-with-multiple-domains/56685/15)):

```
after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-k 4096 -w \/var\/www\/discourse\/public/
        to: |
          -d forum.test.com -d forum2.test.com -d forum-test.test.com -k 4096 -w /var/www/discourse/public

    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-k 4096 --force -w \/var\/www\/discourse\/public/
        to: |
          -d forum.test.com -d forum2.test.com -d forum-test.test.com -k 4096 --force -w /var/www/discourse/public

```

The only discourse the default one (DISCOURSE\_HOSTNAME).  
For the other one, I get the following error when I do a curl:

`curl: (51) SSL: no alternative certificate subject name matches target host name 'forum-test.test.com'`

---

<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: [13.Июль.2018 00:12:46 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/2 "2018-07-13T00:12:46Z")

</div>

Which yml did you add the after\_ssl to?  
Also, one of those links about let’s encrypt describes how to inspect the logs of the script, perhaps some in there will help diagnose.

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [13.Июль.2018 08:33:51 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/3 "2018-07-13T08:33:51Z")

</div>

I added it to `web_only.yml`

---

<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: [13.Июль.2018 09:44:13 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/4 "2018-07-13T09:44:13Z")

</div>

`web.yml` or `web_only.yml`?  
What is the `launcher` command you are using when doing the rebuild?

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [13.Июль.2018 09:56:55 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/5 "2018-07-13T09:56:55Z")

</div>

I renamed it `web_pe.yml`. So I’m using `./launcher rebuild web_pe`

---

<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: [13.Июль.2018 10:18:51 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/6 "2018-07-13T10:18:51Z")

</div>

I can’t see any recent changes that would stop the regex in the `from` working but obviously something is not right. Is there anything unusual in the `templates:` of your web\_pe.yml that could be altering the base ssl before the `after_ssl` happens?

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [20.Август.2018 02:05:10 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/7 "2018-08-20T02:05:10Z")

</div>

Hi,

No, here is the `templates:` of my web\_pe.yml:

```
templates:
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

```

Here is the `after_ssl` hook I have in web\_pe.yml:

```
after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-k 4096 -w \/var\/www\/discourse\/public/
        to: |
          -d forum.pragmaticentrepreneurs.com -d forum.noschangements.fr -k 4096 -w /var/www/discourse/public
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /-k 4096 --force -w \/var\/www\/discourse\/public/
        to: |
          -d forum.pragmaticentrepreneurs.com -d forum.noschangements.fr -k 4096 --force -w /var/www/discourse/public

```

Here are the logs during the bootstrap:

```
I, [2018-08-20T01:52:07.061735 #13] INFO -- : Replacing (?-mix:-k 4096 -w \/var\/www\/discourse\/public) with -d forum.pragmaticentrepreneurs.com -d forum.noschangements.fr -k 4096 -w /var/www/discourse/public
 in /etc/runit/1.d/letsencrypt
I, [2018-08-20T01:52:07.062730 #13] INFO -- : Replacing (?-mix:-k 4096 --force -w \/var\/www\/discourse\/public) with -d forum.pragmaticentrepreneurs.com -d forum.noschangements.fr -k 4096 --force -w /var/www/discourse/public 

```

Here is the etc/nginx/letsencrypt.conf

```
LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue -d forum.pragmaticentrepreneurs.com -k 4096 -w /var/www/discourse/public

if [! "$(cd /shared/letsencrypt/forum.pragmaticentrepreneurs.com && openssl verify -CAfile ca.cer fullchain.cer | grep "OK")"]; then
  # Try to issue the cert again if something goes wrong
  LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue -d forum.pragmaticentrepreneurs.com -k 4096 --force -w /var/www/discourse/public
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --installcert -d forum.pragmaticentrepreneurs.com --fullchainpath /shared/ssl/forum.pragmaticentrepreneurs.com.cer --keypath /shared/ssl/forum.pragmaticentrepreneurs.com.key --reloadcmd "sv reload nginx"

```

The last line should be modified, shouldn’t be?

---

<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: [20.Август.2018 02:31:29 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/8 "2018-08-20T02:31:29Z")

</div>

> [@CamilleRoux](#):
>
> The last line should be modified, shouldn’t be?

No, the file that gets modified in the container is `/etc/runit/1.d/letsencrypt`.

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [20.Август.2018 08:30:25 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/9 "2018-08-20T08:30:25Z")

</div>

Ok! So here is the /etc/runit/1.d/letsencrypt file of my web container:

```console
# cat /etc/runit/1.d/letsencrypt
#!/bin/bash
/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue -d forum.pragmaticentrepreneurs.com -k 4096 -w /var/www/discourse/public

if [! "$(cd /shared/letsencrypt/forum.pragmaticentrepreneurs.com && openssl verify -CAfile ca.cer fullchain.cer | grep "OK")"]; then
  # Try to issue the cert again if something goes wrong
  LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --issue -d forum.pragmaticentrepreneurs.com -k 4096 --force -w /var/www/discourse/public
fi

LE_WORKING_DIR="${LETSENCRYPT_DIR}" /shared/letsencrypt/acme.sh --installcert -d forum.pragmaticentrepreneurs.com --fullchainpath /shared/ssl/forum.pragmaticentrepreneurs.com.cer --keypath /shared/ssl/forum.pragmaticentrepreneurs.com.key --reloadcmd "sv reload nginx"

/usr/sbin/nginx -c /etc/nginx/letsencrypt.conf -s stop

```

---

<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: [20.Август.2018 10:38:45 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/10 "2018-08-20T10:38:45Z")

</div>

Yeah, not sure what’s going on there. Sorry!

> [@CamilleRoux](#):
>
> Here are the logs during the bootstrap:

Which indicate it attempts the replace but since it didn’t happen then it must have failed? I don’t know if there is any other diagnostic that can be used to determine success of fail of a [pups replacement](https://github.com/discourse/pups#replacements).  
All I can think of is either the replace is not working or you are somehow entering the wrong container? Kind of weird, it all looks ok to me.

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [20.Август.2018 11:15:41 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/11 "2018-08-20T11:15:41Z")

</div>

That’s weird. To be sure, I just need to run `./launcher bootstrap web_pe`, right ?

---

<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: [20.Август.2018 11:20:08 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/12 "2018-08-20T11:20:08Z")

</div>

What command do you use to enter the container where you ran the `cat /etc/runit/1.d/letsencrypt` ?

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [20.Август.2018 14:04:54 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/13 "2018-08-20T14:04:54Z")

</div>

I’m running the following:

```console
$ cd /var/discourse/
$ ./launcher enter web_pe
$ cat /etc/runit/1.d/letsencrypt

```

Am I wrong?

PS: Here is what I get when I run `docker ps`

```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b3d5c1de8bae 7660254ef762 "/sbin/boot" 5 weeks ago Up 13 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp web_pe
4f929aed8712 e4dabeee27af "/sbin/boot" 6 weeks ago Up 13 hours data

```

---

<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: [20.Август.2018 14:55:40 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/14 "2018-08-20T14:55:40Z")

</div>

I cannot see anything that looks wrong!

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [20.Август.2018 15:54:25 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/15 "2018-08-20T15:54:25Z")

</div>

Ho I found out! Thank you very much for your help.  
I needed to run `./launcher rebuild` instead of `./launcher bootstrap`

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [19.Сентябрь.2018 16:06:56 UTC](https://meta.discourse.org/t/lets-encrypt-and-multisite-on-2-containers/91962/16 "2018-09-19T16:06:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
