domain.net
domain.net
, I got a second cert for *.domain.net
domain.net
unter "Alternate Domain Names" and chose the SSL cert for domain.net
*.domain.net
domain.net
pointing to the CloudFront distribution for domain.net
and another Alias record for *.domain.net
pointing to the respective CloudFront distribution (see picture below)I went on the website and got an SSL connection for both domain.net
and www.domain.net
, even the redirection from HTTP to HTTPS works. But when I click on a link in the navigation menu for example, like "About", the page I get is NOT domain.net/about
, but http://myenvironment-env.eba-zxsw5igy.us-east-1.elasticbeanstalk.com/about
with a "Not Secure" connection. When I enter the URL manually in the browser, however, like domain.net/about
, I get the correct URL. What may I have done wrong?
Here is the overview over the records from the Hosted Zone.
Configuring Route 53 with the same Laravel application code on Elastic Beanstalk without SSL (+CloudFront) works fine. I am able to access any links on the website, they resolve correctly to domain.net/about
etc.
Maybe I do not connect CloudFront to Elastic Beanstalk correctly? Again, this is what I do in the CloudFront distibution: Under "Origin Domain Name" I put the Elastic Beanstalk URL, I choose "Redirect HTTP to HTTPS", I enter domain.net
unter "Alternate Domain Names" and chose the SSL cert for domain.net
So, I found a solution for my problem. By default, CloudFront sets HTTP Request Header to the origin hostname -- for me this was the ElasticBeanstalk URL. The application then generates links based on that origin.
To change that behavior one has to create a Cache Policy and an Origin Request Policy and add the host header to a whitelist, so CloudFront uses the hist header that is sent from the browser.
This answer gave me a hint on what to do, as well as these AWS resources: