今回のゴール
httpからhttpsへリダイレクトする場合、WEBサーバーの.htaccessを編集する方法がありますが、今回はロードバランサーでリダイレクトを実装してきます。
ちなみに、.htaccessを編集する方法場合は、リダイレクトループにならないように”HTTP:X-Forwarded-Proto”を判定する必要があります。
設定
EC2サービスの[ロードバランサー]を選択して、[リスナー]タブを選択して、httpリスナーの「ルールの表示/編集」をクリックします。

「+」を押して、「ルールの挿入」をクリックします。

[条件]欄は”パス”を選択して、値に”*”を入力
[アクション]欄は”リダイレクト先”を選択して”https”を選択して”443″としました。

確認
Curlで確認すると301(Moved Permanently)でhttpsにリダイレクトされてます。
curl -I http://www.xxxxx.net
HTTP/1.1 301 Moved Permanently
Server: awselb/2.0
Date: Sat, 30 Jan 2021 09:20:35 GMT
Content-Type: text/html
Content-Length: 134
Connection: keep-alive
Location: https://www.xxxxx.net:443/
ブラウザでもhttpのURLにアクセスしてhttpsURLにリダイレクトされていることを確認しました。