wordpressインストールしたので今度はssl対応をします。
参考にさせていただきました。
Let’s EncryptのSSL証明書で、安全なウェブサイトを公開
とりあえず必要なもの入れる
# curl https://dl.eff.org/certbot-auto -o /usr/bin/certbot-auto
# chmod 700 /usr/bin/certbot-auto
certbot-autoで証明書作成する
# certbot-auto certonly \ # 証明書の作成
--webroot \ # 既存のウェブサーバを使うモードを選択
-w /usr/share/nginx/html \ # ドキュメント・ルートのパス
-d secure.zem.jp \ # 認証するドメイン名
--email <メール>@<アドレス> # メールアドレス登録(証明書期限切れの通知用)
問題なければ下記に証明書が作成されます。
ls -l /etc/letsencrypt/live/
nginxにssl設定いれる
server {
listen 443 ssl;
server_name hoge.example.com;
ssl_certificate /etc/letsencrypt/live/hoge.example.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/hoge.example.com/privkey.pem;
自動更新用のcron設定
crontab -e
50 3 * * 0 certbot-auto renew --post-hook "systemctl restart nginx" 1 > /dev/null 2 > /dev/null