We have an angular app living in S3 we would like our domain to serve when there is anything after the / but a flat html page and basic assets to be served from an EC2 when the root of the domain is accessed.
So far we have not gotten anything to work and we're really hoping we can make something work.
So far in cloudfront we have try to make the default route to an EC2 origin and /* and event / route to an S3 origin but nothing seems to be working.
How can we get our domatin example.com serve our EC2 files but anything other than the root, ie. example.com/one, example.com/two, etc. route to the S3 single page app
So far in cloudfront we have try to make the default route to an EC2 origin and /* and event / route to an S3 origin but nothing seems to be working.
If I understand what you're trying to do, that's sort of backwards. * matches everything, including nothing, and including more slashes.
Create a new cache behavior matching the path / and pointing to EC2 origin. This catches the main page.
Create a new cache behavior matching the path /*/* pointing to the EC2 origin. This catches anything in a folder, e.g. /pics/cats.jpg and /pics/cats/funny.jpg and /pics/cats/hilarious/lol.jpg.
If there are any files (other than the main page) in the root of the web server in EC2, create a new cache behavior matching the path /*.* pointing to the EC2 origin. This catches files in the root directory, e.g. /cat.jpg.
Point the default cache behavior to S3. Everything already matched by the two or three other behaviors goes to EC2, and what's left over goes to the bucket, which would be / followed by any characters excluding another / or ., which would have been captured by one of the behaviors routing to EC2.