How to setup Let's Encrypt free ssl certificate on a Discource Instance on Vultr?

Hello,

I am to know how to set up Let’s Encrypt free SSL certificate on a Discourse Instance on Vultr?
Have tried it while the setup was on run, but it failed!

I just set up a $5 instance on VULTR with Ubuntu 18.04. Created the following DNS record on Cloudflare:


Then logged in via SSH and installed updates (apt update && apt upgrade). Rebooted. Then:

root@test:~# git clone https://github.com/discourse/discourse_docker.git /var/discourse
Cloning into '/var/discourse'...
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 4545 (delta 7), reused 9 (delta 0), pack-reused 4523
Receiving objects: 100% (4545/4545), 981.86 KiB | 13.83 MiB/s, done.
Resolving deltas: 100% (2902/2902), done.
root@test:~# cd /var/discourse
root@test:/var/discourse# ./discourse-setup 
Docker not installed. Enter to install from https://get.docker.com/ or Ctrl+C to exit
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13185  100 13185    0     0  94856      0 --:--:-- --:--:-- --:--:-- 94856
# Executing docker install script, commit: 6bf300318ebaab958c4adc341a8c7bb9f3a54a1a
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ [ -n  ]
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:29:11 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:27:45 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.
WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM
or less. This system does not appear to have sufficient swap space.

Without sufficient swap space, your site may not work properly, and future
upgrades of Discourse may not complete successfully.

Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created.
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=7296ed32-7333-4a05-96c2-a5814d9e933b
/swapfile       swap    swap    auto      0       0
vm.swappiness = 10
Ports 80 and 443 are free for use
'samples/standalone.yml' -> 'containers/app.yml'
Found 1GB of memory and 1 physical CPU cores
setting db_shared_buffers = 128MB
setting UNICORN_WORKERS = 2
containers/app.yml memory parameters updated.

Hostname for your Discourse? [discourse.example.com]: test.freenas-community.org
Email address for admin account(s)? [me@example.com,you@example.com]: danb35@gmail.com
SMTP server address? [smtp.example.com]: smtp.mailgun.org
SMTP port? [587]: 
SMTP user name? [postmaster@test.freenas-community.org]: 
SMTP password? [pa$$word]: 05ef745f09d198eee105b2cddbe424f1-bbbc8336-a4d37742
Optional email address for setting up Let's Encrypt? (ENTER to skip) [me@example.com]: danb35@gmail.com

Checking your domain name . . .

Connection to test.freenas-community.org succeeded.

Does this look right?

Hostname      : test.freenas-community.org
Email         : (redacted)
SMTP address  : smtp.mailgun.org
SMTP port     : 587
SMTP username : postmaster@test.freenas-community.org
SMTP password : 05ef745f09d198eee105b2cddbe424f1-bbbc8336-a4d37742
Let's Encrypt : (redacted)

ENTER to continue, 'n' to try again, Ctrl+C to exit: 
Let's Encrypt will be enabled for (redacted)
web.ssl.template.yml enabled

…snip lots of stuff…

2019-09-17 23:56:10.984 UTC [64] LOG:  received fast shutdown request
181:signal-handler (1568764570) Received SIGTERM scheduling shutdown...
181:M 17 Sep 2019 23:56:10.987 # User requested shutdown...
181:M 17 Sep 2019 23:56:10.987 * Saving the final RDB snapshot before exiting.
2019-09-17 23:56:10.988 UTC [64] LOG:  aborting any active transactions
2019-09-17 23:56:10.998 UTC [64] LOG:  worker process: logical replication launcher (PID 73) exited with exit code 1
2019-09-17 23:56:11.006 UTC [68] LOG:  shutting down
181:M 17 Sep 2019 23:56:11.006 * DB saved on disk
181:M 17 Sep 2019 23:56:11.007 # Redis is now ready to exit, bye bye...
2019-09-17 23:56:11.342 UTC [64] LOG:  database system is shut down
sha256:9902b3b87ef8554416de9bd18cb319d16f3f987a708a59a72bd03a119a04bd9c
715b777d15bc45a61960ab68e9356556b6fe6555ed93a319cb0f65d856d1fa4d

+ /usr/bin/docker run --shm-size=512m -d --restart=always -e LANG=en_US.UTF-8 -e RAILS_ENV=production -e UNICORN_WORKERS=2 -e UNICORN_SIDEKIQS=1 -e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 -e RUBY_GC_HEAP_GROWTH_MAX_SLOTS=40000 -e RUBY_GC_HEAP_INIT_SLOTS=400000 -e RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=1.5 -e DISCOURSE_DB_SOCKET=/var/run/postgresql -e DISCOURSE_DB_HOST= -e DISCOURSE_DB_PORT= -e LETSENCRYPT_DIR=/shared/letsencrypt -e DISCOURSE_HOSTNAME=test.freenas-community.org -e DISCOURSE_DEVELOPER_EMAILS=danb35@gmail.com -e DISCOURSE_SMTP_ADDRESS=smtp.mailgun.org -e DISCOURSE_SMTP_PORT=587 -e DISCOURSE_SMTP_USER_NAME=postmaster@test.freenas-community.org -e DISCOURSE_SMTP_PASSWORD=05ef745f09d198eee105b2cddbe424f1-bbbc8336-a4d37742 -e LETSENCRYPT_ACCOUNT_EMAIL=danb35@gmail.com -h test-app -e DOCKER_HOST_IP=172.17.0.1 --name app -t -p 80:80 -p 443:443 -v /var/discourse/shared/standalone:/shared -v /var/discourse/shared/standalone/log/var-log:/var/log --mac-address 02:fb:6d:f6:c7:45 local_discourse/app /sbin/boot
2b1d2b621a42c553eb753cdfb5c67c0d2af7fc50e1eefc22d7c7f8fc47c1d2ed
root@test:/var/discourse# 

Now, browse to http://test.freenas-community.org:


As you see, SSL is active. The cert is from Let’s Encrypt:
image

Everything in the output above is verbatim; the only redactions are the email address used for the admin and for Let’s Encrypt–they’re replaced with (redacted). Don’t worry; this Vultr instance and domain configuration on Mailgun have already been destroyed.

1 Like

Hi there,

I had gone through the same steps, everything went fine log was similar to what was yours Discourse installation for beginners but are willing to be part of the community
I tried opening link to your discourse instance, and the outcome is Screenshot by Lightshot

As I said in my post:

this Vultr instance and domain configuration on Mailgun have already been destroyed.

It was a test to make sure it would work (which it does). There’s nothing unique about a Vultr VPS vs. DigitalOcean or Contabo (or, I’d expect, any other VPS provider), and having confirmed that, I didn’t want to spend any more money to keep the VPS running. So the issue is not one of proper documentation. It isn’t an issue relating to Vultr. The steps in the official docs (which amount to a git clone and running a script) work just fine. Maybe you’re doing something wrong, maybe there’s something unique about your installation, or maybe both are true, but the answer to the question you raise in the subject is “follow the instructions.”

2 Likes

There was a Full-fledged (with SSL) Discourse instance installed earlier on particular domain with the same mailgun,Cloudflare , host settings earlier. It was done by someone else for me.
I broke something later so decided to do it on my own this time for practical learning purpose in order to gain knowledge of not only how to run Discourse but how to get it running as well.
P.S. Just IP is changed this time and so is re-connected to the domain in Cloudflare.