Vultr上のDiscourseインスタンスでLet's Encryptの無料SSL証明書を設定する方法

こんにちは、

Vultr 上の Discourse インスタンスで、Let’s Encrypt の無料 SSL 証明書を設定する方法をお教えください。
セットアップ実行中に試しましたが、失敗してしまいました。

VULTRでUbuntu 18.04の$5インスタンスをセットアップしました。Cloudflareで以下のDNSレコードを作成しました:
image
その後、SSHでログインし、アップデートをインストールしました(apt update && apt upgrade)。再起動後、以下を実行しました:

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

…大量の出力を省略…

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# 

次に、http://test.freenas-community.org にアクセスしました:


ご覧の通り、SSLが有効になっています。証明書はLet’s Encryptから発行されています:

上記の出力はすべて原文通りです。編集されたのは、管理者用とLet’s Encrypt用のメールアドレスのみで、これらは(redacted)に置き換えられています。ご心配なく。このVultrインスタンスとMailgun上のドメイン設定はすでに削除済みです。

こんにちは、

私も同じ手順を踏みましたが、すべて正常に完了しました。ログもあなたと類似していました:Discourse installation for beginners but are willing to be part of the community - #61 by Earlie

あなたの Discourse インスタンスへのリンクを開いてみましたが、結果は以下の通りでした:Screenshot by Lightshot

私の投稿で述べたとおり:

この Vultr インスタンスと Mailgun 上のドメイン設定はすでに削除されています。

動作確認のためのテストでした(実際に動作しました)。Vultr の VPS は DigitalOcean や Contabo(あるいは他のどの VPS プロバイダーも同様と思われます)と比べて特別なものではありません。動作が確認できたため、VPS を稼働させるための追加費用はかけませんでした。したがって、問題は適切なドキュメントの欠如でも、Vultr に特有の問題でもありません。公式ドキュメントの手順(git clone とスクリプトの実行に相当するもの)は問題なく機能します。もしかすると、何か手順を誤っているか、あなたの環境に特有の問題があるか、あるいはその両方かもしれません。しかし、件名で提起された質問に対する答えは「指示に従ってください」です。

以前、特定のドメインに SSL 対応のフル機能な Discourse インスタンスが、同じ Mailgun、Cloudflare、ホスティング設定でインストールされていました。これは以前、他の人が私の代わりに設定してくれたものです。
その後、何らかのトラブルが発生したため、今回は自分自身で設定し直すことにしました。Discourse を運用する方法だけでなく、実際に動作させる方法についても実践的に学び、知識を深めるためです。
追記:今回は IP アドレスのみ変更され、Cloudflare 上でドメインと再接続されています。