ロゴ

KUSANAGIでLet’s EncryptのSSL証明が更新されなかった時の対処法

※本ページはプロモーションが含まれています

プライバシーhogo

KUSANAGI + AWSで運用しているブログがプライバシーエラーで表示されなくなりましたorz

調べてみるとSSL証明が切れた事が原因のようです。

Let’s Encryptは3ヶ月で更新する必要があるので、その更新に失敗したのでしょう。

いろいろ試して復活できましたのでその過程を紹介します。

Let’s Encryptを更新

KUSANAGIにはL証明書を更新するコマンドがあるので実行してみる。

rootユーザになって

# kusanagi update cert

しかしエラーが出て更新できない。

Updating letsencrypt and virtual environment dependencies.....    Error 
Cannot allocate memory while executing command python setup.py egg_info Exception: Traceback (most recent call last): File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/commands/install.py", line 299, in run requirement_set.prepare_files(finder) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/req/req_set.py", line 370, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/req/req_set.py", line 601, in _prepare_file abstract_dist.prep_for_dist() File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/req/req_set.py", line 127, in prep_for_dist self.req_to_install.run_egg_info() File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/req/req_install.py", line 425, in run_egg_info command_desc='python setup.py egg_info') File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/utils/__init__.py", line 678, in call_subprocess cwd=cwd, env=env) File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1224, in _execute_child self.pid = os.fork() OSError:
Cannot allocate memory /usr/lib/kusanagi/lib/functions.sh: line 352: /etc/letsencrypt/live/サイト名/scts/aviator.sct: No such file or directory /usr/lib/kusanagi/lib/functions.sh: line 353: /etc/letsencrypt/live/サイト名/scts/pilot.sct: No such file or directory /usr/lib/kusanagi/lib/functions.sh: line 354: /etc/letsencrypt/live/サイト名/scts/rocketeer.sct: No such file or directory

KUSANAGIをバージョンアップ

調べてみると「KUSANAGI7.8.3」が出ていたのでバージョンアップする。

# yum update -y kusanagi*

再びLet’s Encryptを更新

もう一度Let’s Encryptを更新すると今度はうまくいった。

# kusanagi update cert

これでSSL証明書のエラーは解決できたが、今度は502エラーorz

そして解決へ

nginxを再起動しても解決せず。

# sudo systemctl restart nginx

KUSANAGIをリスタートしたら何故か「Fail」
# kusanagi restart

バージョンアップ情報を見てみると、monit による監視設定を行えるようになったらしく状態を確認してみる。

# kusanagi monit
monit is on
Done.

オンになっているようだ。

このタイミングでブログを更新してみると何故か表示されるようになる。

monitの説明に「5xx の応答コードを検知したときに現在起動しているKUSANAGIのミドルウェアを再起動します。」と書かれているので、一度502エラーをだしたからKUSANAGIのミドルウェアが再起動されて表示されるようになったのかな?

原因

よくわかりませんが、Let’s Encryptの標準的なクライアントが、letsencrypt-auto から、certbot-auto に変更されたことが原因かな?

おわりに

不意に訪れるサーバーのエラーは恐ろしいです。

いろいろ調べている時のドキドキは何度経験しても嫌ですね〜。。。