Came same DNS point to multiple backend systems based on path - .htaccess

I have a domain name registered. www.mydomain.com. I server some paid content on my website. All the requests on all ports for this domain point to tomcat server deployed in Azure Linux VM. I have a requirement to migrate this application to another PaaS platform without affecting existing consumers. I want to first ensure the existing users run out of their subscription next year and on renewal i can migrate them onto new system.(give them new link).
But for now all the new consumers coming in need to be pointed to new backend system with the same Domain name. www.mydomain.com.
Is it possible to divert traffic based on a path? eg
www.mydomain.com/oldcontent will point to azure vm while www.mydomain.com/newcontent points to new PaaS runtime.

You can't use .htaccess if Apache httpd isn't served as a proxy before tomcat. If you are looking for something similar to Apache's mod_rewrite, then try UrlRewriteFilter, with that you shall try URL rewriting, forwarding/redirection or URL masking silently.

Related

Spreading web sites onto more servers

We have 200 customer facing web sites all on one server. They are all ASP.NET running in IIS. Is it possible to move some of them to another server WITHOUT changing the customer's URL? Any links explaining how to do this would be helpful.
If your sits are already registered to specific sub domains, you can simply re-point the names to the new server using dns.
If they are simply different sites under the same domain on IIS you can use your current IIS server to reverse proxy the new ones. Some info is given here
Lastly, you could consider using a load balancer such as netscaler, f5 or application request routing. You would again, point the domain name to this using DNS and the load balancer would send the requests to the correct server.

Understanding bindings in IIS on Azure VM

I have a VM in Azure with IIS running and hosting a website. This site was originally written and hosted by another company and they recently moved it to this VM for us. The binding still shows as the old website name (as hosted on the other company's site) and we still access it by going to the original website URL name in our browser. The developer mentioned to me that I'd need to eventually change the binding to reflect something hosted by my company.
My question is what is my next step? I know how to change the binding, but I'm having trouble knowing what to change it to? Ideally, I'd like to have the site hosted in Azure - the url name does not matter to me, as long as I can change it from the old original one. I created a new Web App in Azure and am trying to point the website to that new url but it's not working. Not sure that's the best route anyway.
If I understood your question correctly, Original website may have a domain name associated with it. You will have to update the DNS records with PIP (static-public IP) of Azure VM (site is now running on IIS on Azure VM).
Trust this helps.

Is it possible to move custom domain from one web app to another?

I have a custom domain www.abc.com configured for web app webapp-a, and I'd like to transfer it to webapp-b without downtime.
If I try to add the domain to webapp-b, I am getting
The host name www.abc.com is already assigned to another Azure website: webapp-a
It there a way to let webapp-a continues to serve the requests, until the DNS cache expires?
Edit: The domain has IP based SSL binding, and the DNS is caching the virtual IP.
I faced the same issue, and was able to solve it in a tricky way.
I created new App Service Plan (previously known as Web Hosting Plan), and assigned "new" Web App to it (you can do it via new portal, or you can create Service Plan during Web App creation).
Then, I was able to assign the same host name to Web Apps in different hosting plans.
Thinking about this, I feel it logical: most probably Service Plan is mapped to physical IIS machine, and you cannot have two sites with the same host name in the same IIS for the obvious reason.
After migration from one DNS to another is done, you can remove unused Service Plan (as you basically pay for each separately).
According to a blog post by the Azure App Service Team in June 2017, it would appear that Azure now supports adding the same custom domain to multiple web apps:
There are scenarios where a customer would like to add the same hostname to multiple web apps in the same subscription, having a geo distributed website is one example. Our custom hostname feature allows you to bypass validation for hostnames that have already been validated. You only need to verify domain ownership when you add a hostname for the first time. For all other apps in the same subscription, you can add the same hostname without creating any DNS records.
You can read the entire blog post at https://blogs.msdn.microsoft.com/appserviceteam/2017/06/21/custom-hostnames-with-app-service/. The quote above was taken from the Adding the same custom hostname to multiple web apps section.
This should help in scenarios such as this where you want to transfer a custom domain name from one web app to another. You can simply add the same custom domain name to both web apps, add any required SSL bindings, and then change the DNS to point to the new web app. As the DNS change propagates, traffic should gradually move over to the new web app without any downtime.
I've tested this myself in the North Europe region and had no problems. Both web apps were in different App Service Plans. I have not tested this scenario with both web apps in the same App Service Plan. Bear in mind that if you're using IP addresses/A records in your DNS, you'd need both web apps to have different IP addresses for the DNS to be able to differentiate between your web apps.
Try assigning the domain to Azure Traffic Manager and have the traffic manager forward the request to the second site. Azure Traffic Manager and Web Apps are two different systems so you might be able to assign the same domain name to a web app and a traffic manager.
Once the DNS cache has expired remove the domain from the old Azure web app and add it to the new one, then finally delete the Traffic Manager account.
Option 2
Set the TTL to something very small, say 5 seconds (I believe your hostname provider should let you set that up), wait for the new TTL to propagate through all the caches. Then switch the custom domain from one app to another, and set the TTL back to it's original value.
This will result in just a few seconds of downtime for any customers, but if you do it at a low-traffic time the effect shouldn't be too bad.

How to convert multiple web sites hosted on IIS to Azure web sites

I currently have a VPS with another provider. On that VPS, I have IIS running with multiple app pools and web sites. I would like to get out of the "server management business", so it would seem that Azure Web Sites (Reserved) would be a great fit. I'm able to get the Azure Web Sites set up, including the custom domain piece. The problem that I can't seem to figure out is how to get the same URLs and behavior that I currently have on my VPS.
For example, I have URLs that look like this right now:
www.foo.com/bar
www.foo.com/baz
wildcard.foo.com/bla
I can't find a way to mimic that in Azure.
Things I've thought of/tried:
Go with one Azure Web Site and have separate virtual directories/app pools in Azure, but googling tells me that isn't supported.
Create 3 Azure Web Sites, one for each of the above. The problem there as I see it is I would need to change to use bar.foo.com, baz.foo.com, and bla.foo.com/wildcard (i.e. lose wildcard subdomain mapping and rework things to have a custom route at the end).
Maybe have one Azure Web Site with a rewrite URL? The problem I think I'd run into there is that it all runs in one app pool, so deploying one piece will affect all 3, and obviously a fault in one app would impact the other 2.
Has anyone else gone down this path and solved it? If the answer is spin up a virtual server, I'll probably just stay where I'm at.
Considering www.foo.com/bar, www.foo.com/baz and wildcard.foo.com/bla are 3 independent web applications that share a domain (foo.com):
Create a Windows Azure Website for each web application. You don't necessarily need to assign custom domain names to them.
Create another, separate website and assign to it the *.foo.com domain using an A record. Refer to Configuring a custom domain name for a Windows Azure web site for instructions. As documented, "With an A record, you map a domain (e.g., contoso.com or www.contoso.com) or a wildcard domain (e.g., *.contoso.com) to the single public IP address of a deployment within a Windows Azure web site. The main benefit of this approach over using CNAMEs is that you can map root domains (e.g., contoso.com) and wildcard domains (e.g., *.contoso.com), in addition to subdomains (e.g., www.contoso.com)."
In this "master" website, set up URL redirection (possibly with status code 307 Temporary Redirect) so that requests go to the appropriate applications.
Alternatively, to avoid the delay of the additional request caused by the redirection, set up the "master" website as a reverse proxy that transparently forwards the request to the "inner" web application and sends the response back to the user.
As yet another alternative, use a custom DNS service to do the routing at the DNS layer.
This way, each web application is independent and you solve the issue of routing requests to the appropriate application.

Point with N sub domains to one WebRole in Azure

Currently I'm trying to port a web application(ASP.NET MVC) to windows azure and have come across a point, I don't know how to solve.
The application is a multi tenant one. Every customer who registers, can enter a name for his instance and is able to surf the site later on over theenteredname.example.com. Further, the domain is used in an ActionFilter to switch between the databases.
How can I realize this in Windows Azure? I know that I must define a binding with defined hostHeader attribute, but as the subdomains a generated dynamically I would have to change the service definition every time a user registers and a new sub domain appears and redeploy it. But that is really not the way I want it.
Any help would be appreciated!
I think the problem is that IIS does not support subdomain wildcard mapping, see here Wildcard subdomains in IIS7. Is it possible to make them like it is in Apache? for more information.
If you would still like to do this there is a solution here http://www.seoconsultants.com/windows/isapi/subdomains/ , but it requires:
Ability to update DNS records
IIS web server admin access
ISAPI_Rewrite component (for Solution 2)
In Windows Azure, if you simply don't assign any host headers to your web role (which is the default), the site will be configured to accept any host header.
You still need to configure wildcard DNS to point to your Azure instance, just as you would for a non-Azure solution.

Resources