Azure: Route subdomain traffic to different backend port - azure

I have multiple sites hosted on the same machine in Azure on different ports:
foobar.com:8000
foobar.com:8001
foobar.com:8002
etc
I would like to address these by subdomain using a reverse proxy;
aaaa.mysite.com ----> foobar.com:8000
bbbb.mysite.com ----> foobar.com:8001
cccc.mysite.com ----> foobar.com:8002
Is it possible to do this in Application Gateway? It only seems to cater for different paths (not subdomains) and doesn't allow ports to be specified for backends.
Is there another Azure feature that allows for this (e.g. Front Door)?

As your requirement to address them by subdomains in APP GW, you could use multi-site hosting.
There are three common mechanisms for enabling multiple site hosting
on the same infrastructure.
Host multiple web applications each on a unique IP address. Use host
name to host multiple web applications on the same IP address. Use
different ports to host multiple web applications on the same IP
address.
For example, you want aaaa.mysite.com ----> foobar.com:8000. The main configuration will be like this: create a multi-site listener, use frontend port 80 and hostname aaaa.mysite.com in this multi-site listener. HTTP setting should specify the port 8000. Make sure the listener is listening on port 80 and HTTP setting configure your custom port for your backend websites.
In this case, you will create 3 Listeners with on same port 80,and specify the hostnames and create 3 HTTP settings, and create rules with corresponding Listener and HTTP settings and backend pool.
The Azure front door also has URL-based routing and Multiple-site hosting ability. Refer to this document.
Update
Backend pools
Create one backend pool and set your Azure VM as the backend in the backend pool.
Listeners
Click multi-site to create a multi-site listener then save it. You need three listeners for your host name.
Type the subdomains as the host name
Health probes
Add a health probe and checkbox pick host name from backend http settings.
HTTP settings
Add three HTTP settings and specify the custom port on each of HTTP settings.
Rules
Add three basic rules with corresponding Listener and HTTP settings and backend pool.

Related

Azure Application Gateway - How to control traffic for different application

I am creating an application gateway and that will be a single point of entry for my multi tenant application. That means I will have multiple application request on this application gateway and then I need to redirect to backend pool. If I will have one application A deployed in app service A then it will listen at port 80 of app gateway. Similar if I have another application, I can expose it using similar way on different port. How can I achieve it. I tried creating multiple rules but not working.
If I read your question correctly, you want multiple app services, each on a potentially different port, to be served by a single application gateway. And it sounds possible you might want to make requests to that application gateway on different port. Sound right?
If so, then what you need to do is something along these lines:
Set up a backend pool for each app service.
Set up an HTTP setting for each backend pool, specifying port, session affinity, protocol, etc. - This will be the port that your App Service takes requests on.
Create a front end IP configuration to expose a public and/or private IP address
Create a listener for each app service, and port that you want to support. This will be the port you want the client requests to use. You can do two listeners per service to allow 80 & 443 (HTTP & HTTPS) traffic, for example.
Create a rule to connect each listener to its backend pool and HTTP setting combination
Optional - set up health probes that target monitoring endpoints based on an URL and a specific HTTP setting entry

How to configure ssl with azure application gateway?

I have to configure my Microsoft Azure server like below scenario
So it is like a request comes with a public IP which represents application gateway having SSL and the request passes from app gateway to the load balancer.
LB just forward to the virtual machine(having SSL) on the basis of the port number.
Here there is only one public IP and virtual machine selected according to the port.
I made the configuration but the only thing I am missing that is SSL configuration with Application gateway and same SSL in a virtual machine.
I don't know my configure pattern is right or wrong please suggest me if you have a good option.
My goal is to achieve the request (with the public IP) passes from the application gateway having SSL to the virtual machine also having the same SSL on the basis of ports with the same public IP, Is there any better option than my configuration pattern?
Please help me, How to achieve it.
You can use the following Settings in Application Gateway and you don't need ILB in-front of your VM.
Create a Application gateway. Create 3 Multi-site Listener. Upload Certificates and enter Host Name and the respective ports.
Create 3 Backend Pool and add your VMs to it.
Create 3 HTTP Settings. Upload authentication certificates and configure respective ports. Create and attach Health Probes to HTTP Settings.
Create rules where you link corresponding listeners with HTTP Settings and backend pool.
Check if the Health Probes are healthy. If yes, then your setup is complete.
In Application Gateway you can achieve end to end SSL and you can create multiple HTTP Settings with different SSL port to achieve this without ILB.
If that is the case you will not get the High Availability as you only have one VM for each SSL port.
Can you explain why you need to use different SSL port for each Machine? Are you hosting multiple Site?
If yes, you can easily achieve with Application Gateway. Please let me know your entire setup and if you have any follow up questions. I am here to help you.

Error 502 while using Application Gateway with App Service Environment

I have setup Application Service environment and trying to access WebApps inside App service environment through Application gateway. Below are the steps I followed to create required setup however I am getting "502 - Web server received an invalid response while acting as a gateway or proxy server" error when I hit the URL that is mapped with application gateway public URL
Created Vnet and created App Service environment inside separate subnet, used subdomain name as dev.xyz.com. I used ILB wild card certificate here issued to *.xyz.com
Created app inside App service environment and named it as "dev-web.dev.xyz.com" and added externally accessible DNS name in the custom domain as "dev-web.xyz.com"
Created Application gateway, added Internal IP address of ILB ( App Service Environment) as back end pool
Created App Gateway-HTTP Settings using port 80 and mapped it with custom probe
Created App Gateway-CustomProbe, host name used here is extenally accessible DNS name which is "dev-web.xyz.com"
Created App Gateway-Listner using host name as extenally accessible DNS name which is "dev-web.xyz.com"
Added a basic rule and mapped above resources with each other
I am still not able to access my Web App after acessing dev-web.xyz.com
I am not sure about how port number used to create listner affect the setup or if I am missing anything.
I also want to implement SSL once I am done with above testing, I would appretiate inputs on how to implement that for above setup.
Created App Gateway-Listner using host name as extenally accessible DNS name which is "dev-web.xyz.com"
After created your App Gateway, a default listener is created to bind the front end IP and port 80 for you. The listener means the App Gateway will monitor the requests which were send to the IP address and port and forwarding the requests to the backend resources. Since you add a host name 'dev-web.xyz.com' as its listener. The App Gateway will also monitor the requests which were send to the host. It will cause a infinite loop forwarding due to the listener host is also marked as the backend host.
To fix the error, you need to remove the App Gateway-Listener record which you added.
I was able to resolve the issue by mapping correct port for the listener. Listener won't harm if you have correct rule setup in the configuration.

Endpoint configuration for Service Fabric

I deployed an app on Service Fabric and there's an HTTP listener spawned inside. How can I configure the listening URL in relation to app/cluster?
More precisely, is there any way to build this URL inside the app by retrieving some environment/role parameter ?
Suppose my cluster is called "test", then it will be available at: test.northeurope.cloudapp.azure.com. If I have an app called "Sample" for which I configured an endpoint called "SampleTypeEndpoint" inside ServiceManifest.xml, what would be the complete URL my app would listen to?
The endpoints you configure in ServiceManifest.xml right now fulfill two purposes:
Allow Service Fabric to provide a unique port from an application port range, if you don't need a well-known port.
When opening a web server that uses http.sys, allow Service Fabric to set up URL ACLs for a random port or a well-known port (80, 443, etc) and certificate ACLs for HTTPS.
That's basically it. The actual address on which you open a listener is up to you to determine. Typically, you open a listener on the node IP and use a NAT for ingress traffic on a domain name. In Azure, the NAT is the Azure Load Balancer which is automatically configured to accept traffic on your cluster's VIP as well as the .region.cloudapp.azure.com domain.
Here's a more thorough overview of how this works on Service Fabric cluster in Azure: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-connect-and-communicate-with-services/

service fabric URL routing

I am using the Azure Load Balancer with Azure service fabric to host multiple self host web applications, I'd like to create a rule that allows me to route based on the users URL request.
So for example if a user navigates to :
http:// domain.com/Site1 then the rule would route to:
http:// domain.com**:8181**/Site1 within the cluster
if the user navigates to:
http:// domain.com/Site2 then the rule would route to:
http:// domain.com**:8282**/Site2 within the cluster
Is this possible with azure service fabric/load balancer?
The Azure Load Balancer only forwards traffic it receives on a port to a node in your cluster on another port (can be the same port or a different internal port). It operates on Layer 4 (TCP, UDP) so it doesn't know anything about HTTP or URLs (although it does allow HTTP probes).
Here are a couple options for multiple web sites:
If you want your web sites hosted internally on different ports (8181 and 8282), then you'll need something else to do URL routing. Azure Traffic Manager or Azure Application Gateway are possible options that would run outside your cluster. Your Azure Load Balancer would need to open a port for each web site, but the benefit is this way you can run your web sites on dedicated nodes and the ALB would automatically route traffic to the appropriate nodes based on which ports are open.
Alternatively, you can set up your own stateless routing service that runs inside your cluster.
Or you can skip routing altogether and just host all of your websites on port 80/443. As long as you're using an http.sys-based web host, which includes Katana, ASP.NET Core 1 WebListener, or anything you build on HttpListener, you can use the same port for all your websites and let the underlying http server route according to either a URL path or hostname, both of which are supported.

Resources