kusanagi sslで後からSSL化する方法

DNSの関係でLet's EncryptのACMEチャレンジに失敗するので
SSL化なしでWordPressをインストールした場合

以下のようなコマンドにより、後付けでSSL化ができる

kusanagi target example.com
kusanagi ssl --email xxx@example.com

kusanagi target example.comコマンドで
SSL化したいプロファイルに切り替えてから

kusanagi ssl –email xxx@example.comコマンドで
Let's EncryptのSSL化処理を走らせる

実行結果
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Requesting a certificate for example.com
Performing the following challenges:
http-01 challenge for example.com
Using the webroot path /home/kusanagi/example.com/DocumentRoot for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your certificate will expire on 2023-08-19. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again. To non-interactively renew *all* of your
   certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

証明書の自動更新を有効にします
nginx/httpd の設定を変更し、再起動しました。
Nginxを使用します。
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/conf.d/example.com_ssl.conf:6
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
kusanagi ssl --https redirect

上記のコマンドを実行すると、ブラウザで
http://example.comのようなURLへアクセスしたときに
https://example.comのようなURLへ自動的にリダイレクトされるようになる

example.com_http.conf抜粋
rewrite ^(.*)$ https://example.com$uri permanent; # SSL ONLY

kusanagi ssl –https redirectコマンドを実行すると、具体的には
/etc/nginx/conf.dディレクトリにある
example.com_http.confのようなファイルに
rewrite ^(.*)$ https://example.com$uri permanent;のようなテキストを書き込んでいるだけである

  • 最終更新: 2023/05/21 17:24