環境
- DragonFly v4.4.3-RELEASE
ログ
letsencrypt 日本語ドキュメント certbot ドキュメント
ものによっては certbot-auto とか letsencrypt-auto とかよくわからんのでまずは検索。
$ sudo pkg search letsencrypt letsencrypt.sh-0.2.0 Pure BASH/ZSH Lets Encrypt client
https://letsencrypt.org/docs/client-options/
中身から察するにおそらくこれらしい https://github.com/lukas2511/letsencrypt.sh
$ cd /usr/local/etc/letsencrypt.sh/
とりあえず下記のものがサンプルとしてあるので .sample を消したものを設置
config.sh domains.txt hook.sh
今回の場合はすでに nginx + php-fpm で動いてるドメインに対して 証明書が欲しいので既存の server ディレクティブに letsencrypt.sh が作るファイルが読めるような設定を追加します。 nginx についてそんなに詳しくないので、今回は .well-known/acme-challenge 以下に来るアクセスをそのまま letsencrypt.sh が生成するディレクトリのパスにしてしまう設定にします。
# for letsencrypt location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /usr/local/etc/letsencrypt.sh/.acme-challenges/; }
/usr/local/etc/letsencrpyt.sh/config.sh
#WELLKNOWN="${BASEDIR}/.acme-challenges" WELLKNOWN="${BASEDIR}/.acme-challenges/.well-known/acme-challenge"
一応 nginx を再起動などしたあと、下記コマンドを実行して取得する。
# /usr/local/bin/letsencrypt.sh --cron
取得した後は下記のように設定すると良いと思います。最低限の設定しかいれてないのでもっと安全にするにはググッてください。
listen 443 ssl; ssl_certificate /usr/local/etc/letsencrypt.sh/certs/example.com/fullchain.pem; ssl_certificate_key /usr/local/etc/letsencrypt.sh/certs/example.com/privkey.pem;
ここまででとりあえず https でアクセスできるようになると思います。
証明書の更新についてですが、インストールしたときに下記のように表示が出ますが、この通りに /etc/periodic.conf に設定を追加すると勝手に更新されるようです。まだ動作確認まではしてません。
To use this script you should copy the examples in /usr/local/etc/letsencrypt.sh/ and at least add a domain and a contact mail address. You should also copy the openssl.cnf.sample file in /usr/local/openssl so you won't get warnings about it missing. In order to run the script regularly to update the certificates add this line to /etc/periodic.conf weekly_letsencrypt_enable="YES" Additionally the following parameters can be added to /etc/periodic.conf To run the certification renenewal as a different user weekly_letsencrypt_user="_letsencrypt" To run a script after the renewal (as root) weekly_letsencrypt_deployscript="/usr/local/etc/letsencrypt.sh/deploy.sh"