内容は
Hello,
Your certificate (or certificates) for the names listed below will expire in 20 days (on 20 May -- --:-- +0000). Please make sure to renew your certificate before then, or visitors to your website will encounter errors.
We recommend renewing certificates automatically when they have a third of their
total lifetime left. For Let's Encrypt's current 90-day certificates, that means
renewing 30 days before expiration. See
https://letsencrypt.org/docs/integration-guide/ for details.
要するにエラーで証明書の更新が出来ないからあと20日でSSLが効かなくなるよ。
ってことみたい。
あれ?前回設定してなかったっけ?
と思って手動で
sudo certbot renew
と打ってみたらエラー出た!
え?なんで???
調べるとどうやらLet's Encryptで登録した時のhttpアドレスに繋ごうとしたらhttpsにリダイレクトしちゃうのが原因みたい。
http://[サイトアドレス]/.well-known/~~へアクセスしているのに
https://[サイトアドレス]/.well-known/~~へ飛ばされちゃうから
「約束が違う!」と怒っているようです。
あー、確かにVirtualHostの設定でリダイレクトしてました。
RedirectMatch 301 .* https://[サイトアドレス]/
この一文ですね。
実はこのリダイレクト方法だと、httpでアクセスして来たものを全てhttpsへリダイレクトしちゃうようで、ある特定のファイルやディレクトリのみhttp接続する。という動作は難しいようです。
(前回はうまくいってたのに?・・・なぜだ〜??ま、いいや)
一部ディレクトリやファイルのみhttpでアクセスさせる場合はRewriteというモジュールを使うと良いそうです。
ー書き方ー
RewriteEngine On
RewriteCond %{REQUEST_URI} !(^/.well-known)
RewriteRule ^(.*)$ https://[サイトアドレス]/$1 [R=301,L]
内容は、RewriteEngineをOnにして、/.well-knownが含まれているアドレスでなければhttpsサイトへリダイレクトさせる。という設定です。(RewriteCondで条件設定が出来るようで、「!」が付く事で否定形として実行される)
これでcartbotが使う/.well-knownディレクトリのみそのままアクセスしてくれます。
とりあえず今回はこれでうまくいったので(ドライランも)、また次回まで様子を見る事にします。
<コマンドメモ>
更新
sudo certbot renew
ドライラン
sudo certbot renew --dry-run
う〜、サーバー管理って難しス・・・