I'm using AWS cloudfront & AWS application load balancer(ALB) for my application. Alb is configured for two listeners for port 80 & 443, both forward traffic to single target group(instance type) on HTTP(default rule).
Cloudfront is set to use ALB as origin which has settings as given.
Origin Protocol Policy = HTTP,
Delivery Method = Web,
Viewer Protocol Policy = HTTP & HTTPS &
Using default cloudfront ssl certificate.
Since my ALB is listening on ports 80 & 443, my application works well on both http & https. Now when I edit the default rule for listener for port 80 to redirect traffic to port 443(previously set to forward to target group on 80 as mentioned earlier) for https redirection, my cloudfront domain got replaced by my ALB domain, and resouces(css, images etc.) are failing to load.
e.g. Before redirection
Url for a resource - daxxxxxxxxxxxx.cloudfront.net/media/jdfghusfe/abc.png ( with cloudfront domain)
After redirection -
Url for a resoucrce - main-albxxxxxx-amazonaws.com/media/jdfghusfe/abc.png
Can anyone help? Thanks in advance.