Self-host on LetsEncrypt server with SSL certificates

Getting a domain

First of all, you need to buy a domain mydomain.com
When self-hosting, we want to make sure our website can be reached securely via https and for this we need the domain to go through CloudFlare.

Setting up CloudFlare

  1. Log in on CloudFlare
  2. Add a new website mydomain.com
  3. Get the new NS records to use (i.e. jerry.ns.cloudflare.com and rafe.ns.cloudflare.com)

Routing domain through CloudFlare

  1. From the domain provider panel, make sure the domain uses the CloudFlare NS records. It might be necessary to manually request this to the provider.
  2. The initial status will be Pending Nameserver Update. Wait until it becomes Active (it is possible to manually refresh with the Re-check now button.

Generating new SSL certificate with LetsEncrypt

  1. If a LetsEncrypt docker image is already running, stop the container docker stop letsencrypt and delete it docker rm letsencrypt.
  2. Create now a new docker image for LetsEncrypt, making sure that mydomain.com is included in the certificate details as a main domain or as extra domains.
docker create \
  --name=letsencrypt \
  --cap-add=NET_ADMIN \
  -e PUID=1027 \
  -e PGID=100 \
  -e TZ=Europe/Stockholm \
  -e URL=mymaindomain.com \
  -e SUBDOMAINS=wildcard \
  -e EXTRA_DOMAINS=www.mydomain.com,www.myotherdomain.com \
  -e VALIDATION=dns \
  -e DNSPLUGIN=cloudflare \
  -e EMAIL=email@email.com \
  -e DHLEVEL=2048\
  -e ONLY_SUBDOMAINS=false\
  -e STAGING=false\
  -p 1443:443 \
  -p 1080:80 \
  -p 9443:8443 \
  -v /volume1/docker/letsencrypt/config:/config \
  --restart unless-stopped \
  linuxserver/letsencrypt

Keep in mind that every domain listed needs to be routed through CloudFlare.