Redirect from non www to www, do I need two app services in azure? - asp.net-mvc

I'm using this solution in redirecting my domain from non www to www. I'm using azure for hosting.
I have created app service for www.domain.com
when I try to access domain.com I get this error:
Should I have to create two app services one for domain.com and one for www.domain.com? or is there a way to accomplish this using one app service?

Should I have to create two app services one for domain.com and one
for www.domain.com? or is there a way to accomplish this using one app
service?
No, you don't need two app services to accomplish this.
Assuming you have configured domain mapping correctly in your DNS provider (e.g. GoDaddy), all you need to do is add both www.domain.com and domain.com in the Hostname mapping in Custom DNS section for your Web App in Azure Portal.

All you need to do it set it up in the DNS section of your domain provider and add custom domains in App Service in Azure Portal as well:
Type Name Value
A # Ip Address of your App Service ( this will cover your main domain )
TXT # yourwebsite.azurewebsites.net ( this will cover your main domain )
CNAME www yourwebsite.azurewebsites.net ( this will conver www section)
Now in the app service side you need to add the custom bindings.
Go to Azure Portal | App Service | settings | custom domains | add host name as below
yourdomain.com
Now you have both domain pointing to same App Service.
More info on step by step guide, I have prepared a post for custom domain check it out.

Related

Using Custom domain, URL mask with CloudRun services and a NEG

I am having issue using the Serverless NEG and URL Masks with Custom domains. Here is some background:
I have multiple services deployed as CloudRun services (login service, search service, feedback service). I am trying to setup a custom domain mapping and use URL Masking so the requests are routed to appropriate services.
I followed the steps outlined here - https://cloud.google.com/load-balancing/docs/https/setting-up-https-serverless
I have created a Load Balancer, Backend Service and a Serverless NEG with a Serverless Network Endpoint Group type as "Cloud Run" and selected "use URL mask" checkbox and provided my custom domain URL like this mycompany.com/ where mycompany.com is the custom domain I have.
NOTE: I am planning to use just one Serverless NEG and leverage URL mask so it can route the requests to appropriate CloudRun service in the backend.
I have updated mycompany.com to use the Public IP address created by the LB from the above steps.
Now, When I type mycompany.com/login or mycompany.com/search, it is not directing me to the appropriate CloudRun services and instead get an error - "This site can’t be reached"
My question: Do I need to setup Custom Domains and add mappings on the CloudRun page specifying mycompany.com and select one of the CloudRun service for me to leverage URL masks ?
I am slightly confused here and the documentation is not helping me here.
Please help.
Regards,
Raj

I purchase the domain and how can I have more than two urls under this domain?

I am trying to host the webapp and the company page under one domain like
Google has
https://www.google.com/
https://support.google.com/
I thought it was two different domains and I've searched for abc.myfirm.io (example) and it does not look like I need to purchase a domain to have that setup.
I am currently using NameCheap
You do not need to register a separate domain with a domain name registrar. You can just create a DNS entry for the subdomain. If the different domains are all aliases for the primary domain (myfirm.io), then use a CNAME record to point the subdomains to myfirm.io. If they are intended to be separate services, create an A record to point the subdomain to the IP it's hosted on.

Map two domains to single Azure website like www.client1.example.com and www.client2.example.com

How we can map two or more domains to a single Azure website?
So in my website, I can map some logic based on domain name.
Like: www.client1.example.com & www.client2.example.com
How we can map two or more domains to a single azure website
You could try to use a CNAME record to map to your Azure app's default domain name, and Azure app service enables us to assign more than one hostname to site. This article shows how to map custom domain name to Azure app, please refer to it.

Subdomains not opening when prefixed with www for site hosted in Azure

I have created a mvc multi tenant site and hosted in Azure. So if my website is:
mysite.com I dynamically create 1.mysite.com, 2.mysite.com depending upon user's sign up information. I have created these
A records:
www.mysite.com 1.2.3.4( Assume this is Azure's IP)
mysite.com 1.2.3.4
*.mysite.com 1.2.3.4
My subdomain websites work well when I open them as 1.mysite.com. But if I try to open www.1.mysite.com it shows me the Azure 404 page not found error.
How can I solve this?
Some systems automatically add the www. A records when a domain or subdomain is entered, it may be that it has/does not on Azure.
There may be a way to make it do this automatically that someone more knowledgabel on Azure may post below but a short term fix would be to manually add the A record.

iis bindings on shared server

I have a scenario where I have many domains (could be hundreds) pointing to my one web application for example
site1.com
site2.com
site3.com
.... etc
All point to my single web app, this app will be in a shared hosting environment.
The only way I can think of configuring these bindings in IIS is to send my shared hosting company an email every time I need a new binding. Is there a better way? for example some how sending all host headers to my site? How do I do that?
You probably need your own IP address to do this. Then you could just not specify a Host name in your binding:
You will need to specify your IP in the binding though.
This means that as long as your DNS points all sites to your IP, then your site should respond.

Resources