question

AbhishekMynam-0367 avatar image
0 Votes"
AbhishekMynam-0367 asked GitaraniSharmaMSFT-4262 answered

How will app gateway resolve which listener to use

Hi,
I created an app gateway with multiple listeners. When I use public ip address, I am using a different port to direct to the correct listener. How can I do the same thing with a DNS name? I have trouble understanding from the documentation.

Thanks
Abhi

azure-application-gateway
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GitaraniSharmaMSFT-4262 avatar image
0 Votes"
GitaraniSharmaMSFT-4262 answered

Hello @AbhishekMynam-0367 ,

Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

Application Gateway allows host-based routing using multi-site HTTP(S) listener. If you want to forward requests to different backend pools based on the host header or host names, you need to choose multi-site listener, where you must also specify a host name that matches with the incoming request.
Application Gateway relies on HTTP 1.1 host headers to host more than one website on the same public IP address and port.

To explain it with an example, it would be as below:

If you have 2 websites (abc.com & dfe.com) running on 2 VMs with IIS servers on port 80. You can create 2 multisite listeners with hostnames abc.com & dfe.com on same port & protocol and associate them with rules which will bind the listener with their respective backend http settings & VMs as backend pools/targets. And then you have to create a CNAME mapping in your DNS to point abc.com & dfe.com to the Application gateway Public IP address (in case of testing, you can make use of host files in your local machine for the name resolution).

Now, when you access abc.com on port 80 or http, the DNS resolves the host name abc.com to the public IP address of the App gateway and the app gateway uses that host header to find the associated listener. Once it finds the correct listener, it will check the associated rule and use the configured http settings to direct the traffic to the configured backend VM. The same happens with dfe.com

So, to answer your question, how will app gateway resolve which listener to use : It will use the incoming host name & port to identify the listener after it resolves the hostname to it's Public IP address (which should be configured as a CNAME in your DNS or local host files).

Please refer the below docs for more information:
https://docs.microsoft.com/en-us/azure/application-gateway/configuration-listeners
https://docs.microsoft.com/en-us/azure/application-gateway/multiple-site-overview
https://docs.microsoft.com/en-us/azure/application-gateway/create-multiple-sites-portal

Kindly let us know if the above helps or you need further assistance on this issue.


Please "Accept the answer" below if the information helped you. This will help us and others in the community as well.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.