What I'm planning is to redirect example.com
into test.example.com
. (that should not be A record - the requirement was the change of the domain so the fact that it is in test domain is apparent.)
However, I found out that APEX domains cannot be CNAME record(link), so I thought redirection on CloudFront or beyond(nginx, expressjs) is appropriate, thereby I set two A records from example.com
and beta.example.com
to CF DNS name.
However with Cached CF I think there might be problem related to redirection.
For example, when a user tries to connect to example.com
as a first hit(CF Cache miss), that request is passed into express and will be responded with 302 redirect to test.example.com
.
However, when another user tries to connect to test.example.com
, the request will be sent to CloudFront as request of /
, so CF will return 302 redirect instead of passing it to express which makes no sence.
How can I solve this issue? Do I have to ditch caching for /
resource or is there another way around it?
Solved by changing Behavior
> Edit
> Cache Based on Selected Request Headers
to whitelist
, and then adding Host
header to whitelist.