bitnamiでLet’s Encryptのサーバ証明書を取得した手順

執筆者:

カテゴリ:

, ,

設定方法

Bitnamiの設定ツールを利用してサーバ証明書を取得する。

sudo /opt/bitnami/bncert-tool

説明

AWS Lightsailで初期に登録したサーバ証明書をk-ponta.comにしてしまい、後になって13.196.238.191/にしておけばよかった後悔。。
初期設定からやり直すのも面倒なので、手動で13.196.238.191/のサーバ証明書を新たに取得できないか調べたところ、bncert-toolコマンドで再取得ができるようなので設定を行う。

サーバにSSHでアクセス後、bncert-toolコマンドを起動すると下記のようなメッセージが表示される。

$ sudo /opt/bitnami/bncert-tool
----------------------------------------------------------------------------
Welcome to the Bitnami HTTPS Configuration tool.

----------------------------------------------------------------------------
Domains

Please provide a valid space-separated list of domains for which you wish to
configure your web server.

Domain list []: 

サーバ証明書を取得したいドメイン名を入力する。英語の説明文は「スペースで区切られた有効なドメインのリストを入力してください Webサーバーを構成します。」とのことなので、k-ponta.comと13.196.238.191/の2つを設定する。

Domain list []: k-ponta.com 13.196.238.191/

次にリダイレクションの有効化の確認が行われる。下記の3つの質問が出てくるので設定する場合は「y」を、設定しない場合は「n」を入力してエンターキーで確定する。

No.英文意味入力値
1Enable HTTP to HTTPS redirectionHTTPのアクセスをHTTPSにリダイレクトするか?y
2Enable non-www to www redirectionwwwが無いURLのアクセスを、www付きのURLにリダイレクトするか?y
3Enable www to non-www redirectionwww付きのURLのアクセスを、wwwが無いURLにリダイレクトするか?n

適宜、答えていく。基本的にディフォルトの選択肢を選んでいけばいいと思う。

----------------------------------------------------------------------------
Enable/disable redirections

Please select the redirections you wish to enable or disable on your Bitnami
installation.

Enable HTTP to HTTPS redirection [Y/n]: y

Enable non-www to www redirection [Y/n]: y

Enable www to non-www redirection [y/N]: n

その後、作業内容が表示されるので問題なければ「y」を入力する。

----------------------------------------------------------------------------
Changes to perform

The following changes will be performed to your Bitnami installation:

1. Stop web server
2. Configure web server to use a free Let's Encrypt certificate for the domains:
k-ponta.com 13.196.238.191/
3. Configure a cron job to automatically renew the certificate each month
4. Configure web server name to: 13.196.238.191/
5. Enable HTTP to HTTPS redirection (example: redirect http://k-ponta.com to
https://k-ponta.com)
6. Enable non-www to www redirection (example: redirect k-ponta.com to
13.196.238.191/)
7. Start web server once all changes have been performed

Do you agree to these changes? [Y/n]: y

設定内容が確認とメールアドレスの入力、契約についてついての表示がされるので問題なければ進める。

----------------------------------------------------------------------------
Create a free HTTPS certificate with Let's Encrypt

Please provide a valid e-mail address for which to associate your Let's Encrypt
certificate.

Domain list: k-ponta.com 13.196.238.191/

Server name: 13.196.238.191/

E-mail address []: メールアドレスを入力

The Let's Encrypt Subscriber Agreement can be found at:

https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf

Do you agree to the Let's Encrypt Subscriber Agreement? [Y/n]: y

設定が始まる。既にk-ponta.comドメインでサーバー証明書を取得済みだったので、既存の設定ファイルのバックアップ先などが表示される。

----------------------------------------------------------------------------
Performing changes to your installation

The Bitnami HTTPS Configuration Tool will perform any necessary actions to your
Bitnami installation. This may take some time, please be patient.

----------------------------------------------------------------------------
Success

The Bitnami HTTPS Configuration Tool succeeded in modifying your installation.

The configuration report is shown below.

Backup files:
* /opt/bitnami/apache/conf/httpd.conf.back.202407020351
* /opt/bitnami/apache/conf/bitnami/bitnami.conf.back.202407020351
* /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf.back.202407020351
* /opt/bitnami/apache/conf/vhosts/wordpress-https-vhost.conf.back.202407020351
* /opt/bitnami/apache/conf/vhosts/wordpress-vhost.conf.back.202407020351

Find more details in the log file:

/tmp/bncert-202407020351.log

If you find any issues, please check Bitnami Support forums at:

https://github.com/bitnami/vms

エンターキーを押して設定を終了する。

Press [Enter] to continue:

設定完了後、https://13.196.238.191/ にアクセスして証明書に問題が無い事を確認する。
http://www.k-ponta.comがhttps://13.196.238.191/に、https://k-ponta.comが、https://13.196.238.191/にリダイレクトされることも合わせて確認する。