> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aviatrix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure Ingress Firewall Setup Solution

> Step-by-step guide to set up an Azure ingress firewall solution using Aviatrix Transit FireNet for traffic inspection.

## Azure Ingress Traffic Inspection Firewall

This document illustrates a simple architecture for Ingress traffic inspection
firewall that leverages Azure Load Balancers,

<a href={"/docs/enterprise/" + "10.1" + "/guides/security/firenet/transit-firenet-overview"}>Transit FireNet</a>
, and
<a href={"/docs/enterprise/" + "10.1" + "/concepts-architectures/components/native-peering-about"}>Azure Transit with Native Spoke VNets</a>
. The solution also allows you to view the client IP address.

The deployment is shown in the below diagram.

<img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/transit-firenet-vnet.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=44be9b0bd8c60307d3d467cb652684c9" alt="Azure Ingress Firewall Setup Diagram" width="1508" height="1036" data-path="images/guides/security/firenet/transit-firenet-vnet.png" />

The key idea is that from a FireNet point of view, the ingress inspection is
simply a VNet-to-VNet traffic inspection. This is accomplished by:

1. Placing an Internet facing Azure Application Gateway in a Spoke VNet (in the
   diagram, this spoke VNet is called Ingress Spoke VNet) to load balance
   traffic to the VNet w<a href={"/docs/enterprise/" + "10.1" +
   "/guides/security/firenet/firewall-launch-attach"}>here</a> applications
   reside (Application Spoke VNet).
2. Managing Spoke Inspection Policies for the Application Spoke VNet traffic
   that requires inspection with the Aviatrix Transit VNet.

In this unified architecture, firewalls can be used for Ingress, Egress,
North-South and VNet-to-VNet filtering. The solution does not need Azure Load
Balancers to directly attach to firewall instances which then requires firewall
instances to source NAT the incoming traffic from the Internet. Firewall
instances can scale out as applications scale for all traffic types.

<Note>
  This architecture works for [Azure Application
  Gateway](https://docs.microsoft.com/en-us/azure/application-gateway/overview).
  You can create multiple load balancers in the Ingress Spoke VNet.
</Note>

## Prerequisite Setup for Azure Ingress Firewall Setup Solution

First, <a href={"/docs/enterprise/" + "10.1" +
"/guides/maintenance/controller-upgrade-workflow"}>upgrade the Aviatrix
Controller</a> to at least version **UserConnect-5.3.1428.**

Deploy the below topology in Azure:

### Azure VNets

* Aviatrix Transit VNet (i.e. 192.168.23.0/24)
* Ingress Spoke VNet (i.e. 10.20.0.0/16)
* Application Spoke VNet (i.e. 10.21.0.0/16)

### Azure Transit with Native Spoke VNets topology

<Note>
  Aviatrix Transit FireNet for Azure Encrypted Transit topology also supports
  this Azure Ingress Firewall Solution.
</Note>

## Deploy an Aviatrix Transit VNET for the Azure Ingress Firewall Setup Solution

Create an Aviatrix Transit VNet with the **Aviatrix FireNet VPC option enabled**.

1. In CoPilot, go to **Cloud Resources > Cloud Assets > VPC/VNets and Subnets**.
2. Click **+ VPC/Vnet** and create a new VPC with the Azure ARM Cloud Type.
3. From the VPC Function drop-down select **Transit + FireNet**.
4. Click **Save**.

### Deploying an Ingress Spoke VNET

Create an Ingress Spoke VNET by creating a VNet as per [Deploy an Aviatrix Transit VNet](#deploy-an-aviatrix-transit-vnet-for-the-azure-ingress-firewall-setup-solution). You can also use an existing VNet.

### Deploying an Application Spoke VNET for the Azure Ingress Firewall Setup Solution

Create an Application Spoke VNET as per the previous step or manually deploy it in the Azure portal. You can also use your existing Application VNET.

## Deploying Azure Transit with Native Spoke VNets Topology

Follow <a href={"/docs/enterprise/" + "10.1" +
"/guides/connectivity/transit/transitvpc-workflow"}>Global Transit Network
Workflow Instructions (AWS/Azure/GCP/OCI)</a> to deploy Azure Transit with
Native Spoke VNets topology.

Create an Aviatrix Transit Gateway in Aviatrix Transit VNET by following the <a href={"/docs/enterprise/" + "10.1" +
"/guides/connectivity/transit/transitvpc-workflow#creating-a-transit-gateway"}>Launch
a Transit Gateway</a> procedure.

<Note>
  For Azure deployment, the Aviatrix Transit Gateway must be launched with the
  option Enable Transit FireNet Function enabled. The minimum Azure FireNet
  gateway size is Standard\_B2ms.
</Note>

## Managing Transit FireNet Policy for Azure Ingress Firewall Setup Solution

Follow

<a href={"/docs/enterprise/" + "10.1" + "/guides/security/firenet/transit-firenet-workflow-azure"}>Aviatrix Transit FireNet creation</a>
to deploy FireNets.

<a href={"/docs/enterprise/" + "10.1" + "/guides/security/firenet/firewall-launch-attach"}>Launch firewall instances</a>
.

Manage a spoke inspection policy for the Application Spoke VNET by referring to

<a href={"/docs/enterprise/" + "10.1" + "/guides/security/firenet/transit-firenet-workflow-azure#configuring-transit-firenet-inspection-policies"}>Configuring FireNet Connection Policies</a>
.

Here is the Firewall information in this example for your reference. Adjust it
depending on your requirements.

| **Example setting**         | **Example value**                                                           |
| --------------------------- | --------------------------------------------------------------------------- |
| Firewall Image              | Palo Alto Networks VM-Series Next-Generation Firewall Bundle 1              |
| Firewall Image Version      | 9.1.0                                                                       |
| Firewall Instance Size      | Standard\_D3\_v2                                                            |
| Management Interface Subnet | Select the subnet whose name contains "gateway-and-firewall-mgmt"           |
| Egress Interface Subnet     | Select the subnet whose name contains "FW-ingress-egress"                   |
| Username                    | Applicable to Azure deployment only. "admin" as a username is not accepted. |
| Attach                      | Check                                                                       |

Set up firewall configuration by referring to

<a href={"/docs/enterprise/" + "10.1" + "/reference/security/firenet/firewall-paloalto-configure-azure"}>Example Config for Palo Alto Network VM-Series</a>
.

<Note>
  In Azure, instead of using the pem file, use username/password to ssh into
  firewall instance to reset the password if needed. Additionally, use the same
  username/password to login into the firewall UI.
</Note>

## Launching an Apache2 Web server in Application Spoke VNET

In Application Spoke VNET, create an Ubuntu Server 18.04 LTS virtual machine and
install Apache2 HTTP Server with custom port 8080.

| Example Setting | Example Value |
| --------------- | ------------- |
| Protocol        | HTTP          |
| Port            | 8080          |

[Install Apache2 HTTP Server](https://websiteforstudents.com/install-the-latest-apache2-2-4-34-on-ubuntu-16-04-17-10-18-04-lts-servers/)
on your Ubuntu server.

[Change the Apache default port to use custom port 8080](https://www.ostechnix.com/how-to-change-apache-ftp-and-ssh-default-port-to-a-custom-port-part-1/).

## Creating Azure Application Gateway

In Ingress Spoke VNET, create an Azure Application Gateway. Make sure you select
the following:

1. Create an Azure Application Gateway in Ingress Spoke VNET.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-application-gw-creation.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=86ca695a35539c5802f649cadd3b7dcb" alt="Azure Application Gateway Creation" width="838" height="927" data-path="images/guides/security/firenet/azure-application-gw-creation.png" />

2. Under Frontends, select **Public** for the Frontend IP address type.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-application-gw-frontend.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=b186da736e268d848b53e36f8975740f" alt="Azure Application Gateway Frontend" width="807" height="345" data-path="images/guides/security/firenet/azure-application-gw-frontend.png" />

3. Select **IP address or hostname** for Target type and configure the private
   IP of Apache2 Web Server for Target in section Backends.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-application-gw-backend.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=a8b88f9302ec3d97f25be77fc9710ca3" alt="Azure Application Gateway Backend" width="1697" height="467" data-path="images/guides/security/firenet/azure-application-gw-backend.png" />

4. Add a routing rule on the Listener depending on your requirements.

   | Example setting | Example value |
   | --------------- | ------------- |
   | Frontend IP     | Public        |
   | Protocol        | HTTP          |
   | Port            | 80            |

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-routing-rule-listener.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=72b6615a2751bc1752cc77652dd06b34" alt="Azure Application Gateway Routing Rule Listener" width="1693" height="541" data-path="images/guides/security/firenet/azure-gw-routing-rule-listener.png" />

5. Add a routing rule on Backend targets and create an HTTP setting depending on
   your requirement.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-rule-target.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=edf1da74743b8ba72b11d4322ea10199" alt="Azure Application Gateway Routing Rule Backend Target" width="1697" height="685" data-path="images/guides/security/firenet/azure-gw-rule-target.png" />

6. Click **Create new** on HTTP settings.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-rule-setting.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=4dacc7bcbbbb0e617e1b2831c696fe94" alt="Azure Application Gateway HTTP Setting" width="1701" height="724" data-path="images/guides/security/firenet/azure-gw-rule-setting.png" />

   | Example Setting  | Example Value |
   | ---------------- | ------------- |
   | Backend protocol | HTTP          |
   | Backend port     | 8080          |

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-rule-backendtwo.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=2e21d7cb85c851e80bda49e9d927c8a3" alt="Azure Application Gateway Backend Target" width="1691" height="689" data-path="images/guides/security/firenet/azure-gw-rule-backendtwo.png" />

7. Review the configuration and click **Create** on the Review + create page.

<Note>
  Refer to [Quickstart: Direct web traffic with Azure Application Gateway -
  Azure
  portal](https://docs.microsoft.com/en-us/azure/application-gateway/quick-create-portal)
  for more information.
</Note>

## Ready to Go

1. Make sure Server (backend pool) status is in a **Healthy** state from the
   Azure portal page Application Gateway > Backend health.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-health-check.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=479fe88b8c670c9d0a7d381a71d803f4" alt="Azure Application Gateway Health Check" width="1098" height="616" data-path="images/guides/security/firenet/azure-gw-health-check.png" />

2. Run a http request targeting the Azure Application Gateway Public IP or DNS
   name.

   a. Find the Frontend public IP address of the Azure Application Gateway from
   the Azure portal page Application Gateway > Overview.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-gw-public-ip.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=5d1c439ce01075db8bb38373a5172a6e" alt="Azure Application Gateway Public IP" width="2948" height="586" data-path="images/guides/security/firenet/azure-gw-public-ip.png" />

   b. Copy the Frontend public IP address of Azure Application Gateway and paste
   it on a browser from your laptop/PC.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-browser.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=3d7a5f695b23269f4999adc80d0f6f97" alt="Azure Browser" width="1043" height="1013" data-path="images/guides/security/firenet/azure-browser.png" />

   c. Perform tcpdump with port 8080 on Apache2 Web server.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-server-tcpdump.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=cf23d10708af03883f9f17ad8710aee3" alt="Azure Server tcpdump" width="1523" height="210" data-path="images/guides/security/firenet/azure-server-tcpdump.png" />

   Azure Application Gateway automatically preserves client original IP address
   in the HTTP header field "X-Forwarded-For (XFF)". Here is an HTTP packet
   example which is opened with Wireshark tool for your reference:

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-server-wireshark.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=cdc3fe0911b773c73f4cbf6bab5fdc71" alt="Azure Server Wireshark" width="3058" height="1822" data-path="images/guides/security/firenet/azure-server-wireshark.png" />

<Note>
  * [Does Application Gateway support X-Forwarded-For headers?](https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-faq#does-application-gateway-support-x-forwarded-for-headers)
  * [What is X-Forwarded-For?](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For)
  * [How do I see X-Forwarded-For in Wireshark?](https://osqa-ask.wireshark.org/questions/13384/display-http-header)
</Note>

## Viewing Traffic Log on Firewall

You can view if traffic is forwarded to the firewall instance by logging in to
the Palo Alto VM-Series console. Go to **Monitor > Logs > Traffic**.

Perform http/https traffic from your laptop/PC to the public IP or the domain
name of Azure Application Gateway.

## Capturing Client IP in Logs

To view the client IP address in the access log, follow the instructions in
[How to save client IP in access logs](https://aws.amazon.com/premiumsupport/knowledge-center/elb-capture-client-ip-addresses/).

1. Find and open Apache configuration file.

   ```bash theme={null}
   #vim /etc/apache2/apache2.conf
   ```

2. In the LogFormat section, add `%{X-Forwarded-For}i` as follows:

   ```
   ...
   LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
   LogFormat "%h %l %u %t \"%r\" %>s %b" common
   ...
   ```

3. Save your changes.

4. Reload the Apache service.

   ```bash theme={null}
   #systemctl reload apache2
   ```

5. Review the public/original client IP on apache2 access log.

   <img src="https://mintcdn.com/aviatrix-14b37c43/mOZ0lmP7pRPIryx3/images/guides/security/firenet/azure-server-apache-accesslog.png?fit=max&auto=format&n=mOZ0lmP7pRPIryx3&q=85&s=855ee591fa7eed01eb6d4ee19ee1266e" alt="Azure Server Apache Access Log" width="1225" height="102" data-path="images/guides/security/firenet/azure-server-apache-accesslog.png" />
