URL path based routing on Azure - azure

I'd need the following config on Azure:
requests to www.domain.com goes to an App Service (call it MainAppService)
requests to www.domain.com/blog/* to a different App Service (call it BlogAppService)
It is important that the url stays www.domain.com/blog/something (a simple redirect to blog.domain.com/something won't work for me here).
MainAppService is a .Net Core app while BlogAppService should be php (yes, WordPress). I wonder if Azure Application Gateway is the only option. Any code based solution without the need to install AAG?

As far as I know, if you want a code-based solution, you may consider adding URL rewrite rules in web app service. It seems that Rewrite Rules only works in one web app service. That is, you could not redirect HTTP-host www.domain.com to blog.domain.com based on rewrite rule.
As your configuration, I think Azure application gateway is an easy and better way to make it.
Configuration example:
Create an application gateway with path-based routing rules using the Azure portal
How to map URL path-based rules in application gateway for your Azure web app service

Related

Apache configuration and redirects in Azure Linux Web Apps

I have a Linux Web App running on Azure with a top-level domain. I want to redirect all traffic coming from mydomain.com to www.mydomain.com (because the free TLS certificate Azure offers only works for non-naked domain names for some reason).
As far as I see this, Apache is the default web server on Linux Web Apps. Unfortunately, it seems I can't just add a Redirect rule in the Apache config files because - I quote: "Any data outside '/home' is not persisted".
Is there any way to do this without having to deal with the redirect in the client application? (e.g. using PHPs header() function)?
The recommended approach for PaaS Web Apps is to use an .htaccess file but it sounds like you don't want to deal with a redirect in the client application.
I can think of two other possibilities for you:
Use Web App Linux Containers
Use Azure Frontdoor URL redirect

How can we use multiple Azure web apps with each with different frameworks under one domain name without using sub-domains?

Example:
our main Azure web app uses ASP.NET, say www.mywebsite.com.
We want www.mywebsite.com/another_framework to transparently route HTTPS requests to and from an internal, ASP MVC website: www.internalwebsite.com. When users open www.mywebsite.com/another_framework they see the content for www.internalwebsite.com transparently.
Apache lets us do this with URL rewriting but how is this done in Azure?
We don’t want to rewrite either of the websites and we don’t want to lose the SEO ranking by having multiple sub-domains.
How is this done in Azure with Web Apps?
When you publish your Web application into Azure, you also publish your web.config file.
In that file you are free to declare your URL rewriting logic.
Take a look at the following articles:
Azure : Create an URL Rewrite Azure Web App
Azure App Services: Understanding URL Re-write

Redirecting from web app behind Azure application gateway

I have two web apps setup in Azure, and for simplicity let's call them webapp1 and webapp2. They sit behind an application gateway, which is selecting the correct web app based on the subdirectory in the URL.
Here's a basic example of how I've set it up:
www.mydomain.com -> webapp1 (the default route)
www.mydomain.com/app -> webapp2
This is working fine, except for one problem: if webapp2 redirects to the login page, for example, the domain in the URL changes to the azurewebsites.net domain. Instead of redirecting to www.mydomain.com/login, it's going to webapp2.azurewebsites.net/login.
I'm fairly new to Azure application gateway, but I know it injects the x-forwarded-* and x-original-host headers. I assumed the gateway would either alter the redirected url request to correct the domain or the config on the web app would use the x-original-host instead. Neither of these things are happening.
Is there a way to configure either the web app or the gateway to make sure the host name doesn't change on redirects? Would this scenario work better with a separate web app/VM with a classic IIS reverse proxy setup instead of the application gateway?
Currently Application Gateway would not overwrite the response from the backend. We do inject X-Original-Host and your application should use that to write the redirect URL correctly back to mydomain.
Example to configure URL rewrite on web app can be found here. An example of rewriting default *.azurewebsites.net domain to a custom domain can be found here

Configuring Azure Application Gateway to Azure web app to route requests by path

I have two web apps (webapp1 and webapp2). I would like to use Application Gateway features where can route using path based redirect.
http://mywebsite/login1 redirect to webapp1
http://mywebsite/login2 redirect to webapp2
Is this possible it possible to do this with Application gateway if so can you please give link or direction on how to do this for web apps prespective
Yes, it is. You can use path-based routing in the Application Gateway to do the job. Here is the link:
Application Gateway URL Routing
The main idea is that you can use the routing rules to point to a specific backend pool. That backend pool will point to whatever servers you want handling that request.
Is this possible it possible to do this with Application gateway
Sure. If you want to do that with Azure WebApp service. But there are two things that we need to do:
1.Make sure that the application root path is the same as you mapped in the Application Gateway. For instance:
if you want route http://mywebsite/login1 -> webapp1
Your webapp1 application root path(home page) should be :http:///login1 You can do quick config at your app service - > Application settings -> Virtual applications and directories:
2.Two custom health prob is needed for Azure web apps , we could use PS script to create them since it seems there is no way to create them on Azure portal.
For more detail information, please refer to this blog.

Azure Api gateway for web apps instead of apis

Is it possible to have an kind of api gateway to redirect requests for different web apps?
Foe example:
Domain: abc.com
Abc.com/ -> abc-com-home.azurewebsites.net
Abc.com/map -> abc-com-map.azurewebsites.net
And every request in teh apps should use rhe same pattern.
Thank you!
Is it possible to have an kind of api gateway to redirect requests for different web apps?
Per my understanding, you could leverage the Set backend service policy to redirect an incoming request to the related back-end. Also, you could leverage the path-based rule for the application gateway with your azure web apps to distribute your request(s) to the relevant azure web app. Details, you could follow here.
Abc.com/ -> abc-com-home.azurewebsites.net Abc.com/map -> abc-com-map.azurewebsites.net
Per my understanding, I would map a custom domain (Abc.com) for abc-com-home.azurewebsites.net, then I would leverage the URL Rewrite for my abc-com-home.azurewebsites.net to redirect the request(s) to the related azure web apps based on the request path.
Yes, the application gateway can do it, but you must do it via powershell. If you need SSL, the you must configure for end to end ssl since webapps cant be a a virtual network.
https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-web-app-powershell

Resources