We have a pretty straight forward requirement in my opinion which is obviously proving to be otherwise:
"Redirect users based on their geo-location to the respective cloud region and use Cloudflare as a CDN for the domain mysubdomain.myparentdomain.com"
Simplifying it further, serve users from US using US cloud region infrastructure and so on. Now, we selected Azure Traffic Manager as it has the capability of resolving the DNS based on Geographical Location.
Let us say that we have two cloud regions as of now:
- US based region having a DNS name as us.cloudapp.azure.com
- EU based region having a DNS name as eu.cloudapp.azure.com
As we are supposed to use Cloudflare as CDN, both of these regions are configured in Cloudflare DNS as below:
- endpoint1.mysubdomain.myparentdomain.com is an alias of us.cloudapp.azure.com (for US service and infrastructure)
- endpoint2.mysubdomain.myparentdomain.com is an alias of eu.cloudapp.azure.com (for EU service and infrastructure)
Traffic Manager is now configured with two endpoints:
- endpoint1.mysubdomain.myparentdomain.com for US traffic
- endpoint2.mysubdomain.myparentdomain.com for EU traffic
In our DNS registrar (outside of Cloudflare), we added a DNS record to resolve our service sa well as below:
- mysubdomain.myparentdomain.com is an alias of my-tm-profile.trafficmanager.net (actual service pointing to the DNS name of the traffic manager)
**Problem Scenario 1:**
1. User from US enters mysubdomain.myparentdomain.com in the browser
2. Browser resolves to traffic manager record
3. Traffic Manager resolves it to the US endpoint
4. US endpoint is proxied by Cloudflare as can be seen above. It is resolved successfully to a Cloudflare IP address.
5. Request lands in Cloudflare but the host header is still mysubdomain.myparentdomain.com
6. Cloudflare tries to find the mysubdomain.myparentdomain.com in its DNS and does not find anything.
7. Cloudflare raises error that origin DNS is not available.
Problem Scenario 2:
To resolve problem 1, mysubdomain.myparentdomain.com DNS record is created in Cloudflare DNS as per below:
mysubdomain.myparentdomain.com is an alias of my-tm-profile.trafficmanager.net (actual service pointing to the DNS name of the traffic manager)
1. User from US enters mysubdomain.myparentdomain.com in the browser
2. Browser resolves to traffic manager record
3. Traffic Manager resolves it to the US endpoint
4. US endpoint is proxied by Cloudflare as can be seen above. It is resolved successfully to a Cloudflare IP address.
5. Request lands in Cloudflare but the host header is still mysubdomain.myparentdomain.com
6. Cloudflare tries to find the mysubdomain.myparentdomain.com in its DNS and finds it pointing to the traffic manager DNS again.
7. Cloudflare goes into a loop of trying to resolve a service which is again proxied by Cloudflare. As per Cloudflare support discussions, this is not doable.
I am not able to see how can I make this possible. Any advice?