I am trying (and mostly succeeded) in setting up a static website in S3 that is served through the urls www.example.com and example.com (both of these work fine over https using a cert provisioned through ACM). It has both of those domains pointing to a cloudfront distribution setup with the S3 bucket as its endpoint in Route 53.
I also have multiple Elastic Beanstalk instances that are being served through different sub domains. app.example.com points to the one serving pages other than the landing page and api.example.com is serving the api. All of this works perfectly fine and is setup through Route 53 for the subdomains.
The only thing that does not work is I have the following setup for redirection:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>login/</KeyPrefixEquals>
</Condition>
<Redirect>
<Protocol>https</Protocol>
<HostName>app.example.com</HostName>
<ReplaceKeyPrefixWith>login/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
So what I am hoping happens is that when someone visits (www.)example.com it goes to the landing page that is hosted in S3 and when they go to (www.)example.com/login it goes to (www.)app.example.com/login (Which points to an ELB). This does NOT work when I use HTTPS to access https://(www.)example.com/login but does if I just go to my s3 bucket url over http: http://example.com.s3-website.ca-central-1.amazonaws.com/login That successfully redirects to app.example.com/login.
Not sure what I am missing but do redirect rules in the S3 static website properties not work over HTTPS because the host name is different than the host name of the actualy s3 bucket? That is all I can think of since it works fine if i access the endpoint from the s3 url without going through my domain name with the SSL cert.