Azure Reverse Proxy is a service that allows you to expose a web application or service behind a firewall to the internet. It acts as a reverse proxy server, routing incoming HTTP requests to the internal server.
One of the key features of Azure Reverse Proxy is its ability to provide secure access to your application or service. This is achieved through SSL termination, which encrypts all incoming and outgoing traffic.
Azure Reverse Proxy also provides load balancing, which distributes incoming traffic across multiple instances of your application or service. This helps to improve responsiveness and availability.
By using Azure Reverse Proxy, you can simplify your infrastructure and reduce the complexity of managing multiple servers and services.
What Is Application Gateway?
Azure Application Gateway is a reverse proxy that operates at Layer 3, 4, and 7 for IP-based, TCP/UDP-based, URL-based, and Host Header-based routing.
It's a powerful tool that allows incoming connections from external sources, making it a great solution for global routing clients to the closest available service region.
The Gateway has optional Web Application Firewall (WAF) capability to protect against common web attacks.
With Application Gateway, you can offload SSL and accelerate websites at the network edge, which can significantly improve performance.
It also allows for private IP space routing and between your resources to build your regional application.
By using Application Gateway, you can easily route across zones and into your VNET.
When to Use Application Gateway
When to use the Application Gateway? It's a great tool for global routing, directing clients to the closest available service region.
Azure Application Gateway can help offload SSL and accelerate websites at the network edge, making it a great choice for high-traffic websites.
For regional or internal routing, the Application Gateway is perfect for routing across zones and into your VNET, utilizing private IP space for routing between resources.
This means you can use the Application Gateway to build your regional application, taking advantage of its ability to route between your resources.
Zone Redundancy
Zone Redundancy is a powerful feature that makes your Azure Reverse Proxy setup more resilient to failures.
By deploying your Application Gateway or WAF across multiple Availability Zones, you can remove the need to provision separate instances in each zone with a Traffic Manager.
This allows you to choose a single zone or multiple zones where Application Gateway instances are deployed, making it more robust.
You can also distribute the back-end pool for your applications across availability zones, adding another layer of redundancy.
This means that if one zone fails, your application will still be accessible through the other zones.
Features and Functionality
Azure reverse proxy offers several features and functionality that make it a powerful tool for routing and load balancing.
You can use it to route global clients to the closest available service region, offload SSL and accelerate websites at the network edge.
This allows for private IP space routing and between your resources to build your regional application, making it ideal for regional or internal routing across zones and into your VNET.
Rewriting HTTPS Headers
Rewriting HTTPS headers is a powerful feature that allows you to add security-related header fields like HSTS and X-XSS-Protection.
You can use Application Gateway to add, remove, or update HTTP request and response headers while the request and response packets move between the client and backend pools.
Application Gateway allows you to add conditions to ensure that the specified headers are rewritten only when certain conditions are met, making it easier to create powerful rewrite rules.
All headers in requests and responses can be modified, except for the Host, Connection, and Upgrade headers.
This is particularly useful for removing response header fields that might reveal sensitive information, and removing port information from X-Forwarded-For headers.
By using server variables, you can store additional information about requests and responses, making it easier to create complex rewrite rules.
This feature is especially useful for securing your application and protecting it from common web attacks.
Socket Routing
Socket Routing allows for one Application Gateway to front-end multiple applications.
This flexibility is made possible by the ability to make routing decisions based on IP and Port requests.
With Socket Routing, you can easily manage traffic to different applications behind a single gateway.
This can be especially useful in scenarios where you need to route traffic to different applications based on specific IP addresses or ports.
Multiple-Site Hosting
Multiple-site hosting is a feature that allows you to configure more than one website on the same Application Gateway instance.
You can add up to 100 websites to one application gateway.
Each website can be directed to its own pool, giving you a flexible topology for your deployments.
For example, Application Gateway can serve traffic for navatron.com and navatron.nl from two server pools.
Two subdomains of the same parent domain can also be hosted on the same application gateway deployment.
This includes hosting subdomains like https://blog.navatron.com and https://api.navatron.com on a single Application Gateway deployment.
End-to-End SSL
End-to-End SSL is a crucial feature for maintaining SSL encryption throughout the entire communication process. Application Gateway can be configured for End-to-End SSL, which decrypts traffic, evaluates it based on configured policies, modifies headers as needed, and then re-encrypts traffic before sending it to back-end servers.
This process ensures that sensitive data remains protected from start to finish. In this scenario, the Application Gateway acts as a middleman, handling the decryption and re-encryption of traffic.
Application Gateway supports End-to-End SSL by terminating and re-establishing TLS connections. This allows for flexible configuration and management of SSL encryption policies.
To illustrate this, consider the following comparison of TLS termination and End-to-End TLS with Application Gateway:
- TLS Termination: Application Gateway decrypts traffic and forwards it to back-end servers without re-encryption.
- End-to-End TLS: Application Gateway decrypts traffic, evaluates and modifies headers as needed, and then re-encrypts traffic before forwarding it to back-end servers.
Using IIS or App Service as a Reverse Proxy
Using IIS or App Service as a Reverse Proxy can be a viable alternative to Application Gateway, but it has some limitations. You can add, remove, or update HTTP request and response headers while the request and response packets move between the client and backend pools.
However, this approach requires more configuration and can be less efficient than using Application Gateway. All headers in requests and responses can be modified, except for the Host, Connection, and Upgrade headers.
One key advantage of using IIS or App Service is that it can handle redirection from HTTP to HTTPS, but it might not be as straightforward as using Application Gateway's native redirection feature. Application Gateway can handle this scenario natively, simplifying configs and freeing up resources on the web servers themselves.
Additionally, IIS or App Service might not be able to offload SSL and accelerate websites at the network edge as efficiently as Application Gateway. Global Route clients to the closest available service region. Offload SSL and accelerate websites at the network edge.
If you're looking to terminate SSL/TLS at the gateway, Application Gateway is a better choice. It supports SSL/TLS termination at the Gateway, after which traffic typically flows unencrypted to the back-end servers. This feature allows web servers to be unburdened from costly encryption and decryption overhead.
Here's a comparison of the two approaches:
Session Affinity
Session Affinity is a feature that allows the Application Gateway to direct subsequent traffic from a user session to the same server for processing by using gateway-managed cookies.
This is particularly useful in cases where the session state is saved locally on the server for a user session, such as when you want to keep a user session on the same server.
The cookie-based session affinity feature is a key component of this functionality, enabling the Application Gateway to manage cookies for each user session.
By doing so, the Application Gateway ensures that subsequent requests from the same user are routed to the same server, reducing the likelihood of session state inconsistencies and improving overall application performance.
Custom Error Pages
Custom error pages can be created instead of displaying default error pages, allowing for custom branding and layout.
This feature is particularly useful for displaying a custom maintenance page if the application isn't reachable, giving users a clear indication of what's going on.
A custom error page can also be used to display an unauthorized access page if a malicious request is sent to a web application, helping to protect users from potential threats.
Custom error pages can replace HTTP 502 and 403 return codes, providing a more user-friendly experience.
If an error originates from the back-end servers, it's passed along unmodified back to the caller, and a custom error page isn't displayed.
Application Gateway can display a custom error page when a request can't reach the back-end, giving users a clear message about what's happening.
WebSocket Support
Application Gateway provides native support for the WebSocket protocol.
There is no user-configurable setting to selectively enable or disable WebSocket support.
The WebSocket protocol enables full-duplex communication between a server and a client over a long-running TCP connection.
HTTP/2 Support
Application Gateway provides native support for the HTTP/2 protocol, allowing for full-duplex communication between a server and a client over a long-running TCP connection.
This enables a more interactive communication between the web server and the client, which can be bidirectional without the need for polling as required in HTTP-based implementations.
The HTTP/2 protocol has low overhead, unlike HTTP, and can reuse the same TCP connection for multiple requests/responses.
This results in a more efficient resource utilization.
These protocols are designed to work over traditional HTTP ports of 80 and 443.
Nginx
Nginx is a powerful web server that can be used as a reverse proxy.
It's capable of forwarding requests to an underlying host, which is useful for setting up a secure connection.
You can specify the underlying host in the nginx configuration, such as simpleauth1.azurewebsites.net, and the port to use, like 443.
A location block is used to tell nginx to proxy all requests from the root (/) to the declared upstream, which is the Azure Web App in this case.
Adding the line proxy_set_header Host simpleauth1.azurewebsites.net; can help resolve issues with domain names not being recognized by Azure.
App Proxy Works
Application Proxy lets you publish external public HTTP/S URL endpoints in the Azure cloud. These URL endpoints connect to the internal URL of your organization’s application server.
The Application Proxy service runs in the cloud and is a key component of Azure App Proxy. It works in conjunction with the Application Proxy connectors and Azure AD to enable single sign-on (SSO).
The Application Proxy connectors are lightweight agents that run on an on-prem server. They carry out any additional authentication steps and forward the request to the application server.
Azure AD is the identity provider that works together with Application Proxy to offer single SSO to on-premises applications. This allows end-users to access web applications that are hosted on-premises in the same way they’d access an SaaS application or Microsoft 365.
Here are the key components of Azure App Proxy:
- The Application Proxy service—runs in the cloud
- The Application Proxy connectors—lightweight agents that run on an on-prem server
- Azure AD—the identity provider
Best Practices for Publishing Apps
When configuring Application Gateway, it's essential to consider the security implications of rewriting HTTP/HTTPS headers. By adding security-related header fields like HSTS/X-XSS-Protection, you can significantly improve the security of your application.
You can also remove response header fields that might reveal sensitive information, such as port information from X-Forwarded-For headers. This helps protect your application from potential security threats.
Application Gateway allows you to add conditions to ensure that specified headers are rewritten only when certain conditions are met. This level of control is crucial for ensuring that your security configurations are effective.
To make the most of Application Gateway, you should also consider the benefits of multiple-site hosting. With this feature, you can configure more than one website on the same Application Gateway instance, directing each website to its own pool.
For example, you can serve traffic for navatron.com and navatron.nl from two server pools called MainServerPool and DutchServerPool. This approach can help you create a more efficient topology for your deployments.
Redirection is another essential feature of Application Gateway. It can handle scenarios like redirecting from HTTP to HTTPS, simplifying configs and freeing up resources on web servers.
Azure App Proxy is a powerful tool for publishing external public HTTP/S URL endpoints in the Azure cloud. It connects to the internal URL of your organization's application server, enabling single sign-on (SSO) for end-users.
To make Azure App Proxy work effectively, you need to consider the best practices for publishing applications via this service. Here are a few key takeaways:
- Use the Application Proxy service to run in the cloud, and the Application Proxy connectors to run on-prem servers.
- Integrate your on-premises web applications with Azure AD to enable SSO.
- Use conditional access policies to ensure users comply with security requirements.
By following these best practices, you can ensure that your applications are published securely and efficiently via Azure App Proxy.
Frequently Asked Questions
Is Azure Application Gateway a reverse proxy?
Yes, Azure Application Gateway acts as a reverse proxy by establishing a new connection to a backend server after receiving a client connection. This Layer 4 operation enables secure and efficient communication between clients and backend servers.
Is Azure Front Door a reverse proxy?
Yes, Azure Front Door can act as a reverse proxy for publicly reachable apps, directing traffic and improving security. Learn more about how to use Azure Front Door in Scenario 4 of this article.
Sources
- https://clemens.ms/protect-your-web-applications-using-azure-application-gateway/
- https://azureossd.github.io/2023/03/27/Configuring-NGINX-as-a-reverse-proxy-on-Azure-Linux-Virtual-Machines/
- https://anduin.aiursoft.cn/post/2020/1/11/use-iis-or-azure-app-service-as-a-reverse-proxy
- https://www.withouttheloop.com/articles/2017-07-23-nginx-letsencrypt-azure-web-app/
- https://pathlock.com/azure-ad-application-proxy-workflow-and-best-practices/
Featured Images: pexels.com