SSL認証Let's Encryptの導入 (Certbot)

上記内容は古いため下記参照のこと。

certbotのインストール

https://eff-certbot.readthedocs.io/en/stable/install.html

注) パッケージで提供されているバージョンは古いため、snapによる最新バージョンのインストールが推奨されています。

ex) Ubuntu20.04+Nginx

Dockerによる起動

スタンドアローンで証明書を取得する場合などは、snapやシステムに直接インストールすることなくDockerイメージによる起動が便利です。

Certbot on Docker
https://eff-certbot.readthedocs.io/en/stable/install.html#running-with-docker

スタンドアローン
https://certbot.eff.org/docs/using.html#standalone

certonly:単に指定ドメインの認証を取得したいだけの場合

$ sudo docker run -it --rm --name certbot \
            -v "$PWD/letsencrypt:/etc/letsencrypt" \
            -v "/var/lib/letsencrypt:/var/lib/letsencrypt" \
            -p 80:80 \
            certbot/certbot certonly --standalone -d stun.example.com

コンテナ内の /etc/letsencrypt/live ディレクトリに証明書が作成されるため、-vオプションによりホスト側のアプリ指定のディレクトリと共有させます。