My setup is as follows:
- user types example.com on the browser
- request goes to AWS CloudFront, which redirects HTTP to HTTPS, and forwards the request to the AWS Elastic LoadBalancer (elb.example.com)
- LoadBalancer forwards the request to the EC2 instance running PHP Laravel framework
- EC2 responds normally
- user views the page correctly at example.com with everything else transparent to him
All this is perfectly what I want, HOWEVER .....
- If the user navigates to any button on the page, the url on the browser will become elb.example.com (it should stay example.com)
- If I go to view page source, all the links to any button on the page has the base url of elb.example.com (it should be example.com)
The reason is because EC2 see the request coming from the load balancer so it assumes the base url is elb.example.com and generates all links accordingly.
How do make EC2 see the base url as example.com ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…