Aktualisiert: 29. Okt 2018
Amazon Load balancer has listeners that listen on port 80 and 443. I wanted my app to automatically forward all requests made to http port 80 to secure connection on https. I was able to configure it on Listener level.
Usually depending on which endpoint listeners are listening on, you can define which service or application behind your load balancer will handle the request. This is especially useful with micro-services architecture.
For my app however, both listeners were forwarding requests to the same target group with my EC2 instance in it. So all I had to do was to redirect listener for port 80 to https instead of forwarding it to another target group.
The steps are as follows:
Go in edit view of a listener for port 80. Delete forward to target group and add a new action. Select Redirect to https, port 443 and you can leave the host, query and params at default.
After this change, you can go back to the list of listeners and you should see the http listener rule redirecting to https.
This change will take some time to propagate and after that when you type your domain address in a browser it should always go to the secure domain.