無料SSL証明書の Let's Encrypt の設定

証明書取得更新ツール certbot のインストール

公式サイトの手順に従いインストール

# yum -y install certbot python2-certbot-nginx

証明書の発行

certbot certonly --agree-tos --nginx -m メールアドレス -d ドメイン名

# Nginx の設定ファイルに非推奨ディレクティブが ssl on; があるとエラー 
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/xxxx

# Nginx の設定ファイルに日本語とかが入っているとエラー
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 4: ordinal not in range(128)

Nginx のリロード

systemctl reload nginx

証明書の自動更新設定

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null