Custom Domain to Azure CDN Endpoint with and without www - azure

I have created an Azure CDN, an endpoint and working fine.
Created a CNAME www.mydomain.com to myazurecdn.azureedge.net
Created another CNAME mydomain.com to www.mydomain.com
In Azure Endpoint, Custom Domain, I updated www.mydomain.com and it got propagated.
Now, when I navigate to www.mydomain.com, everything works fine but when I navigate to mydomain.com i get below response.
Our services aren't available right nowWe're working to
restore all services as soon as possible. Please check back soon.
Note: As Azure endpoint accepts multiple custom domain, I could add both www.mydomain.com and mydomain.com but it is not correct way, as I have many <a> tags with www.mydomain.com/link.
What to be done now to instruct system to use same route for mydomain.com and www.mydomain.com?
Is domain redirect from domain.com to www.mydomain.com only option?

Have a look at this,
A custom domain and its subdomain can be associated with only a single
endpoint at a time. However, you can use different subdomains from the
same custom domain for different Azure service endpoints by using
multiple CNAME records. You can also map a custom domain with
different subdomains to the same CDN endpoint.
You can use different subdomains in the same endpoint. Alternatively, I think you also could create two endpoints, one is for the root domain without www, the other is for a subdomain with www.

I would say, you can implement redirection in your server or CDN.
When someone tries to access example.com, you can do a 301 by sending http://www.example.com in the location header.

Related

Redirect www to non-www on Azure Dns Zone

I have created Azure DNS Zone to manage redirections which use domain from namecheap.
Let's assume that my website is www.johndoe.com and currently website working well for johndoe.com but when I call www.johndoe.com it doesn't work well.
I have CNAME record and in CNAME redirect to redirect but unfortunately it doesn't work.
When I have call www.johndoe.com response message is as following...
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.
Please take into account that DNS does not provide a redirect.
An additional A or CNAME record only provides your IP address to people that navigate to that specific URL. When www.johndoe.com and johndoe.com both resolve to your web server, this means each page on your site has two addresses. This is horrible for things like SEO.
For a true redirect (and a 301 is preferred for SEO), set something up in the service that's handling the traffic coming in.
For instance: if you have an App Service running ASP.NET, setup the redirect in web.config. If you have Front Door (or a CDN) in place, use the rules engine to create a redirect with the correct condition and action.
Here's an example redirect in an Azure Front Door Classic Resource (this one redirects the other way):

AddRedirectToWww() redirecting to wrong domain

I'm using the AddRedirectToWww rule for the rewriter middleware and I keep getting redirected to the wrong domain.
For context, my website is hosted on azure app service which has a default domain of myapp.azurewebsites.net. I have a custom domain say myapp.com and www.myapp.com.
I setup the rule so traffic from myapp.com gets redirect to www.myapp.com. However, what is happening is upon hitting myapp.com I get a redirect towards www.myapp.azurewebsites.net.
Any reason for why this is so? Does this middleware require specific request headers to determine the right host?
From the scenario and configuration you described, it looks like you have not set CNAME and TXT record correctly. You need to configure this in your Domain Registrar/Provider.
You need to map a subdomain (for example, www.myapp.com) by using a CNAME record.
Map a root domain (for example, myapp.com) by using an A record.
Kindly refer this document for step-step process.

How to configure DNS for Azure CDN with multiple endpoints and root

I own a domain "x.wiki" which is managed via domains.google
I have a website, which is split up into multiple endpoints using azure cdn.
sub1-x.azureedge.net - Subdomain 1 (intended site route with all content)
sub2-x.azureedge.net - Subdomain 2 (subdomain with limited
content)
sub3-x.azureedge.net - Subdomain 3 (subdomain with limited
content)
I want to serve these as follows.
www.x.wiki -> sub1-x.azureedge.net
x.wiki -> sub1-x.azureedge.net
sub2.x.wiki -> sub2-x.azureedge.net
sub3.x.wiki -> sub3-x.azureedge.net
currently it only works with www. / sub2. / sub3.
x.wiki doesnt resolve
Does anyone know how I can get this working correctly?
My understanding is that due to limitations with CNAME i cannot do this easily, however azureCDN to my knowledge does not give me an IP for use with custom domains.
Here is my DNS configuration.
You also use alias records to point your DNS zone apex x.wiki to Azure CDN endpoints. If your domain DNS provider does not support alias record for root domain, you could optionally to host your domain in Azure DNS.
In the Azure DNS zone, you could create an alias record like this,
Then, you will see one A record and one CNAME for your CDN endpoint.
After the records are verified, you could add the hostname x.wiki in the custom domain of your CDN endpoint.
Alternatively, you could try the workaround in this blog.
Set up a CNAME “cdnverify.” to
“cdnverify..azureedge.net”. Once all is verified and set up
(including SSL provisioning if desired), delete the CNAME and use
ANAME for the root record.
The answer to this is to redirect root to WWW from my DNS provider.
The cdnverify cname is not necessary.
https://www.tachyonstemplates.com/2018/google-domains-forward-root/
May re-open this if i still cant get adsense to resolve the root (because it is a redirect)

GitHub Pages https/www Redirect

How can I get https://www.test.com to redirect to https://test.com when using GitHub pages to host a static website?
I recently enabled TLS (provided by GitHub/Lets Encrypt) for my static site by setting A records at my DNS provider (namecheap). I've also chosen to "Enforce HTTPS" option in my GitHub repository's settings, which handles redirecting requests from http://test.com to https://test.com. I have a redirect configured through my DNS provider which forwards http://www.test.com to https://test.com, but the one missing piece of the puzzle is forwarding https://www.test.com to https://test.com.
Regarding this issue, GitHub says, "If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar."
... and my DNS provider says, "It is not possible to set up a URL redirect in the account for the TCP port forwarding from http://www.domain.tld (uses port 80) to https://www.domain.tld (working via port 443)."
I seem to be caught in an infinite loop of the two services saying the other should provide this functionality.
What worked for me:
Change your custom domain to be prefixed with www., like this:
Save the settings and wait until www.example.com resolves and works.
Remove the www. prefix and save again.
Wait for browser and DNS caches to invalidate.
All combinations should lead to https://example.com/ and no SSL error should appear.
GitHub Pages handles redirection between the apex domain and www subdomain automatically as long as you configure the DNS records correctly.
From the GitHub Pages documentation on configuring an apex domain:
If you configure the correct records for each domain type through your DNS provider, GitHub Pages will automatically create redirects between the domains. For example, if you configure www.example.com as the custom domain for your site, and you have GitHub Pages DNS records set up for the apex and www domains, then example.com will redirect to www.example.com. Note that automatic redirects only apply to the www subdomain.
While the docs discuss redirecting from the apex domain to the www subdomain, the reverse direction works as well.
If the apex domain is the desired target (as in this question): set the custom domain value to just example.com.
If the www subdomain is the desired target: set the custom domain value to www.example.com.
Again, this works as long as DNS records are correctly configured for both the apex domain and www subdomain, as described in the docs.
Not the point of this question, but the question When should one use a 'www' subdomain? offers some good insight on using the www or not.

Can a secondary domain point to an existing nameserver and be redirected?

I have a client that has two domains.
ex:
domain1.net.br and domain2.net.
domain1.net.br is already registered in my aws route53 and has 4 nameservers assigned to it.
I told my client that he should use the same nameservers for domain2.net to make it redirect.
I tought this would work but It didn't.
Shouldn't any domain having the nameservers be able to redirect to another domain?
I told my client that he should use the same nameservers for domain2.net to make it redirect.
I tought this would work but It didn't.
You are correct, this will not work. Route 53 assigned unique name servers for each of your domains.
Shouldn't any domain having the nameservers be able to redirect to another domain?
HTTP redirects are not a function of a name server, but of a web server. The easiest way to redirect domain2.net to domain1.net.br is to create an Amazon S3 bucket and utilize the Web Page Redirects feature.

Resources