Nginxで設定したVirtualHostの複数ドメインをSSLに対応させた
今回やったこと
- VirtualHostで設定したそれぞれのドメインをSSLに対応させた
前提
- Debian 10
- Nginx
- VirtualHostの設定をして、2つのドメインを使ってそれぞれ別のhtmlを表示させている
概要
公式の手順通り進めてたけど、証明書をインストールする段階でNginxのプラグインがないとログに出ており、そこで対応したことを残す。
証明書のインストール
certbotの公式を使用して進める。
SoftwareにNginx
、SystemにDebian 10
を選択すると手順が表示されるので、その通りに実行する。(エラーで詰まったところまでは割愛)
つまったところ
sudo certbot --nginx
を実行した時に以下のエラーが表示される。
/var/log/letsencrypt/letsencrypt.log
を読めと書いてあるので従う。
$ sudo certbot --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log The requested nginx plugin does not appear to be installed
ログを見ると、Nginxのプラグインが不足しているぽい。
ここでこちらの記事を参考にさせていただきました。
2021-08-04 15:38:00,827:DEBUG:certbot.main:certbot version: 0.31.0 2021-08-04 15:38:00,827:DEBUG:certbot.main:Arguments: ['--nginx'] 2021-08-04 15:38:00,828:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot) 2021-08-04 15:38:00,833:DEBUG:certbot.log:Root logging level set at 20 2021-08-04 15:38:00,833:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log 2021-08-04 15:38:00,834:DEBUG:certbot.plugins.selection:Requested authenticator nginx and installer nginx 2021-08-04 15:38:00,834:DEBUG:certbot.plugins.selection:No candidate plugin 2021-08-04 15:38:00,834:DEBUG:certbot.plugins.selection:Selected authenticator None and installer None
python3-certbot-nginx
をインストール。
sudo apt install python3-certbot-nginx
動いた。
$ sudo certbot --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel):