サイト運営しているとドメインを変更することってよくありますよね(無い)
僕はあったので困りました。
なのでその時の対処方法を備忘録がてら次回実施する時のために手順をメモメモ
条件
新しいドメインを持っている
ネームサーバーの設定を完了している
ネームサーバーの設定を完了している
注意
すでに運用しているサイトに対して行うのであれば一時的にアクセスできなくなるのでメンテナンス画面が表示されるようにしておいたほうが親切ですね。
内輪だけつかうなら「あっいまからちょっとあれであれなんでつながりませーん」でいいんでないかな(ほじほじ)
手順
- 証明書を失効させる
- ssl.confファイルを削除する
- 証明書発行
- サーバー再起動
証明書を失効させる
# certbot -auto revoke --cert-path=/etc/letsencrypt/live/www.xxxxx.com/cert.pem Saving debug log to /var/log/letsencrypt/letsencrypt.log Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you like to delete the cert(s) you just revoked, along with all earlier and later versions of the cert? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es (recommended)/(N)o: y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted all files relating to certificate www.xxxxx.com. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully revoked the certificate that was located at /etc/letsencrypt/live/www.xxxxx.com/cert.pem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ssl.confファイルを削除する
削除するっていうと物騒なので名前変えて無効化するのがよいですね。
rm /etc/httpd/conf/xxx-le-ssl.conf
もしくは
mv /etc/httpd/conf/xxx-le-ssl.conf /etc/httpd/conf/xxx-le-ssl_.conf
証明書発行
ここからは前回ssl証明書を発行したときと同じ手順で行っていきます。
この時点でhttpd.confに古いドメイン情報があればコメントアウトか削除しておくとよいでしょう。
certbot --apache -d www.new-dimein.com
サーバー再起動
systemctl restart httpd
参考サイト
https://free-ssl.jp/command/
https://weblabo.oscasierra.net/letsencrypt-revoke/
Tips
httpd.confについて
virtualHostのconfigファイルをインクルードする方法が手軽だと思います。
例えばこのようなファイルを作成しhttpd.confで読み込んでいた場合は「-le-ssl」が末尾に付与されたファイルが作成されてhttpd.confで読み込む記述も自動でしてくれる
つまり
/etc/httpd/conf/vhost.conf #これがあると
/etc/httpd/conf/vhost-le-ssl.conf #自動で作ってくれる!
cerbotを実行するとhttpd.confの中身が自動で追記される
Include /etc/httpd/conf/vhost.conf
Include /etc/httpd/conf/vhost-le-ssl.conf #自動で内容を記述してくれる!
オプション等はここが見やすいです
https://free-ssl.jp/command/
コメント