Azure Application Gateway - Reverse Proxy

Victor Gomes 20 Reputation points
2023-08-18T11:40:16.6566667+00:00

Hello,

I have an Application Gateway configured that has the private IP 10.179.0.xx1. Behind the AppGW, there are 2 Virtual Machines with the private IPs 10.179.0.xx2 and 10.179.0.xx3, configured as a backend.

When I try to access the website published in these two Virtual Machines using the AppGW IP (10.179.0.xx1), it work's as expected and load balance the connection between the two servers. The point here is that the browser redirect the connection to the IP (10.179.0.xx2 or 10.179.0.xx3) of one of the Virtual Machines and doesn't maintain the IP of the Application Gateway.

I would like to know how to make the Application Gateway work as Reverse Proxy. Is it possible to modify this and make every time that I type https://10.179.0.xx1 in the browser, it show's me the website published in the two VMs, but the address still with the IP of the Application Gatway?

Thank you

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,216 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshu katara 16,720 Reputation points MVP Moderator
    2023-08-18T11:50:26.7666667+00:00

    It sounds like you want to configure your Azure Application Gateway to act as a reverse proxy and forward traffic to your backend virtual machines while still preserving the original URL (in this case, the IP of the Application Gateway) in the browser's address bar. This is achievable through a combination of listener and URL path-based routing rules.

    Here's a step-by-step guide on how to achieve this:

    Create Backend Pools:

    • In your Application Gateway configuration, ensure that you have defined backend pools for your two virtual machines (10.179.0.xx2 and 10.179.0.xx3).

    Create HTTP Settings:

    • Set up HTTP settings for your Application Gateway. These settings include protocol, port, and timeout configurations.

    Create Listeners:

    • Create an HTTPS listener for your Application Gateway. This listener should use a frontend IP configuration with the private IP (10.179.0.xx1) of the Application Gateway.

    Create a URL Path-Based Routing Rule:

    • Now, you'll create a URL path-based routing rule to forward traffic to your backend pools while preserving the original URL in the browser.
    • Under the listener you created, go to the "Rules" tab and click on "Add a routing rule".
    • Configure the rule as follows:
    • Name: Give your rule a meaningful name.
    • Listener: Choose the HTTPS listener you created earlier.
    • Use the following settings for your conditions:
    • If any of the following match the patterns: /*
    • Use the following settings for your routing settings:
    • Route to: Choose your backend pool.
    • Rewrite URL: Enabled (this preserves the original URL in the browser).

    Test the Configuration:

    • With the URL path-based routing rule in place, accessing https://10.179.0.xx1 in a browser should now load balance traffic to your backend virtual machines (10.179.0.xx2 and 10.179.0.xx3), while the browser's address bar will still show https://10.179.0.xx1.

    Keep in mind that this setup might require additional configuration if your backend application has absolute URLs, as those URLs may need to be adjusted to work correctly behind the reverse proxy. Also, make sure that your backend virtual machines are configured to respond to requests for 10.179.0.xx1.

    .

    Azure's documentation -->https://learn.microsoft.com/en-us/azure/application-gateway/features and https://learn.microsoft.com/en-us/azure/application-gateway/url-route-overview

    1 person found this answer helpful.

  2. msrini-MSFT 9,291 Reputation points Microsoft Employee
    2023-08-19T07:14:27.13+00:00

    Hi,

    In an ideal scenario, your Application Gateway's IP will be preserved. If you have an HTTP to HTTPS re-direction configured in your Web server, you might see this kind of behavior. You can still change this behavior:

    In your HTTP settings, you can override host name with your Application Gateway's IP, so that the IP will not change.

    Note: You will need to configure your Web application to accept traffic when the hostname is configured as the AppGW's IP.

    Regards,

    Karthik Srinivas


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.