Azure dns forward www to naked no-www - azure

I own for a website (example.com (GoDaddy)) and I set the name servers to Azure and manage DNS from there. I don't know enough about DNS to know how to properly do what I'm trying to do or the pros/cons. I have SSL always set in my AppService.
I want www.example.com to forward to example.com (on both http and https). Currently, I have both registered and bound to a cert in the AppServices and it works over https. The following links work in fact.
http://example.azurewebsites.net forwards to -> https
https://example.azurewebsites.net works/secure (seems to be using *.azurewebsites.net cert)
http://example.com forwards to https://example.com
https://example.com works/secure using example.com cert
http://www.example.com (forwards to https)
https://www.example.com (works using example.com cert).
So, all of these work and are secure... but I'd like ALL of them to forward to the naked and secure: https://example.com
I setup (In Azure) www CNAME to point to example.azurewebsites.net. Can I get this to happen through dns configuration or do I need to modify the actual AppService code to detect www and forward?
Also, if later I want someOtherAPI.example.com (can it point to another totally different AppService and use the same cert or will it need another cert?

It seems you want to know two points in your question:
So, all of these work and are secure... but I'd like ALL of them to
forward to the naked and secure: https://example.com
By default, Azure provides a wildcard cert *.azurewebsites.net for the domain azurewebsites.net, so you could use https for the domain and its subdomain. If you want to forward all traffic forward to the URL https://example.com, you need to change your code like URL rewrite or URL redirect in the web.config file. View More details here1 and here2
Also, if later I want someOtherAPI.example.com (can it point to
another totally different AppService and use the same cert or will it
need another cert?
The SSL cert DNS name must match the domain name in the website URL. So if you want to secure the website for the domain someOtherAPI.example.com, you need an SSL cert DNS name as someOtherAPI.example.com or wildcard domain *.example.com for this website.
Hope this could help you.

Related

Azure web app - Godaddy redirect www to non-www

I try to redirect my Azure web app from www.website.com to website.com and I cannot find a way.
I already check many solutions online and follow the steps, like here: Redirect from non www to www, do I need two app services in azure?
but no luck.
In go daddy I have:
Type Name Value
A # myIp
TXT # website.azurewebsites.net
CNAME www website.azurewebsites.net
and in Azure Portal I set:
-> custom domains
website.azurewebsites.net (given by default from azure)
website.com
www.website.com
-> TSL/SSL Settings
website.com
www.website.com
but still, when I go to www.website.com, I see my website but I don't get forward to website.com
Any idea what else could I do/what am I missing?
You have DNS records in Godady
Type Name Value
A # myIp
TXT # website.azurewebsites.net
CNAME www website.azurewebsites.net
Azure WebApp cannot make redirect from www.website.com to website.com
You can configure domain Redirect in Godaddy
https://www.godaddy.com/help/edit-my-domain-forwarding-19978
https://www.godaddy.com/help/forward-my-domain-12123
I got in contact with GoDaddy service and they told me that under the hood, GoDaddy use Forward service to deal with www to non-www.
Basically, GoDaddy forward service, has its own server which has no certificate installed. That's my the warning.
SSL certificate are per domain, per server.
Solution: I must redirect at server level, not DNS level if I want the www.mywebsite.com to work properly while rediretcing to non-www.

Azure CDN - How to redirect from root domain to www? Some rules from Rules engine don't apply

I created a static page using Azure Storage and CDN with Microsoft Standard pricing tier. I need to redirect user from example.com to https://www.example.com (with www), but my rules doesn't seem to work - only http to https redirection rule works so when I type example.com I'm redirected to https://example.com
That's my rules configuration:
That's domain records:
Both options are added in custom domains for this cdn:
The problem is that at first user is forwarded to https://example.com where there is no cert and privacy error appears and rules are not applied.
Rules could be changed to this:
so now user is forwarded from example.com to https://www.example.com, but if somebody will type https://example.com he will still see an error. Solution to this could be buy SSL cert, because Azure CDN doesn't allow CDN Managed SSL for apex domain.
Goal
Redirect root/apex domain to WWW subdomain, using Azure CDN without buying/making your own cert.
Can this be done?
Yes
How?
Use below config, remember to use Moved 301, not "Permanent Redirect 308"

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.

CNAME on a custom domain is changing the url on the address bar with a 301 redirect

I am building a web app and i will like to access the application from another domain using a CNAME record.
The app is running on my main domain (my-domain.com) and i have a second domain (another-domain.com)
I have set up the CNAME for another-domain.com to point to my-domain.com but whenever i visit another-domain.com i get a 301 redirect to my-domain.com
Is there something i need to do that i haven't done yet?
This is my first time working with CNAME so suggestions are welcomed.
Thanks
CNAME is a DNS alias for an A record (IP Address).
DNS doesn't know anything about 301 Status (which is part of the HTTP protocol).
So the 301 response you're getting is coming from your website (or possibly your firewall/router/load balancer). Check your server logs to see which application is returning the 301 (apache, IIS, NGinX, HA-Proxy, etc), then check the configuration to ensure it's performing the way you want.
For example, in Apache you might have created a new VirtualHost for another-domain.com with
Redirect permanent my-domain.com
If you want the same web content displayed no matter what the domain, consider changing the my-domain.com VirtualHost configuration, adding :
ServerAlias another-domain.com

Redirect non-www to www using DNS Zone Editor?

I've just purchased a new traffic tracking service, which requires my domain (registered at GoDaddy) to have a CNAME record pointing to their servers.
I've done that fine, and it's now working.
However, when typing it in without the "www", I get a 404 error page.
My question is, what would I type in the DNS Zone Editor to redirect my "non-www" domain to the "www" domain?
For example, I need my URL to do this…
http://mydomain.com/1234 --> http://www.mydomain.com/1234
Would it be done using an "A name record" or something? Or another way?
I've searched everywhere and can't find a solution that works, so hopefully you can help.
Thanks,
James.
Assuming you just want to send all traffic from mydomain.com (known as your 'naked' domain) to www.mydomain.com you should be able to use domain forwarding. In GoDaddy this will be in the Domain Manager under "Domain Information" at the bottom.
For those having their servers with AWS and domain registered at Godaddy:
I set up my A record with 2 entries (Host: # and www) as below to redirect to my server in AWS through the public ip. This catches the URLs with/without the www prefix
Using DNS Manager we cannot redirect our (naked) domain
(example.com)
to www version
(www.example.com)
we need web hosting for this purpose. because I try it but results are zero. Using domain hosting it is imposible in my views..
By using Forward domain how can i forward the is here. In screen short. there is a option Forward to
My domain is in
(www.example.com)
Version. if i use this option it will redirect to
(example.com)
According to these settings.
Note my :
1] Domain name : GoDaddy
2] Hosted (code) : Heroku (minimum $25/month dyno, dyno is virtual machine, dyno is equivalent to EC2 of AWS)
3] SSL certificate : Bought on GoDaddy ; and endpoint on Heroku (heroku minimum SSL endpoint on $20/month)
These were working :
https://www.example.com/
http://www.example.com/
www.example.com
These were not working :
example.com
http://example.com/
https://example.com/
My heroku ssl add on had :
www.example.com
example.com
Solution:
step 1:in cmd/shell
Copy IP address above and use in step 2
step 2:in GoDaddy account
DONE!!!
Note :
1)remove forwarding if you have to use this solution
2)CNAME - www - sslendpoint

Resources