Restrict your LoadBalancer's public access, let internet have access to your app only via CloudFont.
- Understanding of how LoadBalancer work.
- Your app delivering content via CDN from LoadBalancer.
- Application Load Balancer with at least one listener.
As of now I believe you have at least configured Listeners for your Load Balancer.
lets update the rules for the listener
- goto LoadBalaner from EC2 dashboard and select your LB.
- Then Select listeners and Click View/edit rules
Delete the current forward to , and click add actionthen Return fixed response....
In this stage we create a Custom header.
- Goto + and click Insert Rule.
- Add condition as Http header.
- add X-Custom-Header as header Header name, give a random unique value RandomValue-1234567890.
- Now foward this to your TargetGroup
- Now Save it.
- Goto CloudFront console and select your distribution.
Select Orgins and click edit.
Under Add custom header - optional
🎉Congratulations🎉 you have successfully secured your load balancer.