見出し画像

Let's encryptに後からサブドメインのSSLを追加する(リバースプロキシ編)

さくらのVPSでnginx+Apacheのリバースプロキシをしています。
後からSSL追加してぇ!ってなった時に便利な方法。

まずサーバーを止める

nginx+apacheだと一番簡単なのはstandaloneでのSSL更新なので、まずWEBサーバーを止めます。

sudo nginx -s stop
sudo systemctl stop apache2

サブドメインを追加する

ドメイン exsample.com にサブドメイン sample1.exsample.com sample2.exsample.comがすでに設定されている。そこにsample3.exsample.comを追加したい。という場合、以下のようになります。

certbot certonly --force-renew --cert-name example.com -d example.com -d sample1.exsample.com -d sample2.exsample.com -d sample3.exsample.com

--cert-name にすでに設定しているメインのSSLのドメイン、-dオプションですでに設定しているサブドメインも含む全サブドメインを指定。

How would you like to authenticate with the ACME CA?


1: Apache Web Server plugin (apache)
2: Nginx Web Server plugin (nginx)
3: Spin up a temporary webserver (standalone)
4: Place files in webroot directory (webroot)


と聞かれるので3を選択。

Did you intend to make this change?


(U)pdate cert/(C)ancel:

と聞かれるのでuを選択。

Congratulations!が出れば成功です。WEBサーバーの再起動を忘れないように。

確認は

sudo certbot certificates

です。

参考:https://n314.hatenablog.com/entry/2020/05/06/134312

トラベラーという昔のSFRPGのソロジャーナル化を頑張っています。印刷代の足しにしてやるぜ!という嬉しい方がいましたらメンバーシップ入って頂けると喜びます。