Search code examples
azurednscdnazure-cdn

Azure CDN is redirecting traffic with a custom domain


I have a setup like this:

A website at domain abc.com

Azure CDN points to it. So if you go to abc.azuredge.net you see abc.com content. In the URL bar you see abc.azuredge.net.

I have another domain, qwe.com, I want abc.qwe.com to be the custom domain for the CDN endpoint. In qwe DNS settings, I set a CNAME record, for abc to point to abc.azuredge.net. I add the abc.qwe.com as a custom domain in the CDN endpoint.

My expectation: I go to abc.qwe.com. I see abc.com content, from abc.qwe.com domain.

What happens: I go to abc.qwe.com, it responds with a parmanent redirect to abc.com.

Did I miss configured something, or it's supposed to work this way? I don't understand why it doesn't do a redirect on abc.azureedge.net, but if I add a layer on top of it, suddenly it just redirects to the origin.


Solution

  • In my case it ended up being not related to CDN. It was actually rules on a server that were doing a redirect under certain conditions, e.g. http to https, or www redirect.

    As a side note, https redirect can be tricky. Now chrome uses https by default, so if you type in the url, it will go to https, thus no redirect. But if you select your custom domain text in azure portal and choose "go to xxx", it will actually go to http version, which will result in a redirect. So you might be under impression that you are going to https and it was redirecting, when in fact it was http.

    I was planning to delete the question, but Erik H commented that he's having same issue so I decided to self-answer. Maybe it will help someone.