How to send all traffic to a certain path with a application gateway (azure) - azure

I'm struggling to find a way of sending all traffic into a app gw to a certain website path.
Say my website is, stackoverflow.devops.com.
I have a App Service backend with the domain stackoverflow.devops.com.
The idea going forwards is to send all traffic to that website to a traffic manager, doing geolocation routing. Currently, if you're in Europe, it routes to an application gateway where the path is fine, and this works.
If you're in the states, it routes to a different application gateway (with the same backend pool) and I want to change the url to stackoverflow.devops.com/us for any traffic going through this app gw.
I've tried URL rewrites but getting a 'too many redirects' error.
Thanks!

It sounds like you are redirecting back to the public DNS name and going back out to Traffic Manager which is creating a loop.
You should be able to specify '/us' as the URL path value on your rewrite rule.
I'm curious about what you are trying to achieve here though if the backend pool is the same for both application gateways. Would you not want to have another App Service in the US region also?

Related

Azure front door to support multiple web app by path under same domain

I have a question about azure front door potential for this. So I have 2 web site running by Azure App Services and I need then under same domain name but different path of URL like this:
App Service A -> www.something.com
App Service B -> www.something.com/b-product
I'm not sure this is possible to use Azure front door or I should use another service to solve this problem.
Do somebody can suggestion to me?
Yes you can do this fairly easily, when you create your routing rule you have the option tom specify patterns to match, there you can specify /foo and have this forwarded to pool A where app service A lives
Then you create a different routing rule with /bar pattern to match and forward that to pool B
Then you can repeat this until you get what you need.
you can also have one routing rule match the / domain as per your example you don't have to use a /foo pattern you can also do /* but I always found it easier to use /foo/* and /bar/* to keep the same URL structure
As suggested by Junnas , you can use the front door rules engine
Alternatively , you can use application gateway listeners
If you want all of your requests (for any domain) to be accepted and forwarded to backend pools, choose basic. Learn how to create an application gateway with a basic listener.
If you want to forward requests to different backend pools based on the host header or host names, choose multi-site listener, where you must also specify a host name that matches with the incoming request. This is because Application Gateway relies on HTTP 1.1 host headers to host more than one website on the same public IP address and port. To learn more, see hosting multiple sites using Application Gateway.

Why is inbound IP for Azure webapp returning 404 for endpoints but using url works fine?

I have an .Net Core app published on Azure, the webapp has an endpoint that is publicly accesible.
When creating an HTTP POST request using the full url {azure-url}/results it works as expected. However a client needs to use this endpoint but his system transforms urls into IP addresses before creating a request (not sure why to be honest).
I've checked through Azure properties which is the IP address of the webapp which also matches when doing a nslookup. Problem is that when I replace the url with the IP address and make a request it returns 404.
Has anyone experienced something like this? I wonder if it's related to some Azure configuration I'm not aware of.
Azure App Service is a multi-tenant service. Meaning that other apps may share the same servers and thus the same inbound IPs. In order for your request to be routed properly to your app, it needs the domain name, not just the IP.
There is a way to get a static inbound IP by using a custom domain. I haven't tried that but I would assume even then you will not be able to call the service on that IP.

Azure Application Gateway - Prevent redirection

I've a AppService running with an endpoint www.test.com. I've deployed an Application Geteway and set up a backend pool to forward traffic from AG to www.test.com. I've then created DNS records to point www.test.org to the AG IP. When I navigate to www.test.org the browser does a 301 redirect to www.test.com.
I want to prevent the redirection as from the users point of view, however I want the request to forward www.test.com but the browser to remain the same.
Interesting I had previously done this on another site with the exact same config (I think) with the only exception it is using the tier WAF2.
In the HTTPSettings, update the Override Hostname field with "www.test.com". When you do that the actual request will be for "www.test.org" and when the request goes to your backend pool, it will have "www.test.com" as the hostname.
This should fix your issue. You don't need to configure any redirect in your backend server.

Can I map (CNAME) a custom domain to a subdomain that is part of a Wildcard on Azure Web Apps?

I have a website on Azure Cloud Services, and I have enabled a wildcard for my website like: *.mywebsite.com
Then if a customer registers and select as his subdomain: client1.mywebsite.com, I only save the subdomain associated with my customer in the database. I don't need to do anything on the portal. This works as well on Azure Web Apps (Azure Websites).
Now, if my client goes to his domain provider and sets a DNS entry like:
www.client1.com CNAME client1.mywebsite.com
I can handle that correctly in Cloud Services without having to register "www.client1.com" in the Azure Portal. Is that possible in Azure Websites without having to add www.client1.com to the Azure Portal?
Short answer, no, it is not possible.
Explanation.
What you type in the address bar is the name that is presented to a web server in the HTTP request. Regardless of the underlying DNS responses. If a DNS look up of www.example.com provides an IP Address, whether a CNAME or an A record, that is where it will go and get data from. The only way to change that is with a HTTP Redirect.
In Azure the incoming server name is used to direct traffic to the correct web app (On the same set of IP Addresses there might be thousands of other websites registered) The only way it knows how to distinguish where to send the request is from the incoming server name.
Why this worked on Cloud Services.
Behind a cloud service was an IP Address that was unique to your servers behind it. When a cloud service got a HTTP request, it would process it, because there was nowhere else to send it.

How to use azure traffic management with a custom service url endpoint?

I want to provide failover proof url for my service endpoint to users using traffic management. I have a service instance running at http://vm1.cloudapp.net/myservice:8888/index.html. If this instance goes down then the service auto starts on vm2 at http://vm2.cloudapp.net/myservice:8888/index.html n vice versa.
I want azure to hide the underlying service urls to user and expose the service at http://myservice.trafficmanager.net
Is this possible? If so, how ? From reading the documentation of traffic manager service, it looks like you can failover only at DNS level and not at url endpoint level
There are several parts to this.
Firstly, you are right that Traffic Manager works at the DNS level. It doesn't see your HTTP traffic and hence doesn't see the full URL. Since your two services instances have different DNS names, there's no issue here--you configure Traffic Manager with both names as separate 'endpoints', and Traffic Manager will direct traffic to those endpoints by providing one or other in each DNS response.
Secondly, you want to hide the URL paths. Since Traffic Manager works at the DNS level, it doesn't see your HTTP traffic and hence doesn't see the URL, only the domain name. Therefore this is something you have to handle at the application level (just as you would for a single-instance service that doesn't use Traffic Manager).
The only thing to be careful of is to make sure you configure the correct URL port and path in the Traffic Manager endpoint monitoring configuration. Just make sure that Traffic Manager shows your endpoints as 'Online', and you're good.
Jonathan

Resources