Part 2 – Configuring Azure Application Gateways with AD FS

In Part 1 of Configuring Azure Application Gateway with AD FS  we covered the existing architecture AD FS and the target AD FS architecture.  Finally we deployed an Application Gateway with a basic configuration.

So lets have a look at the logical configuration of what AD FS with a Application Gateway running a Web Application Firewall will look like.

Azure AD FS WAF Logical v0.1

Now we are ready to get cracking with some configuration work!

Backend Pools

This is where the Application Gateway will be delivering interesting traffic too.  In this case it will be the following virtual machines:

  • VMF-WE-WAP01
  • VMF-WE-WAP02

Select Application Gateway > Backend Pool and then add in your virtual machines.  It should look something like this.

WAF 03

Frontend Listener

This is the external port that the Application Gateway listens for interesting traffic.  In Part 1, we chose HTTP, the reason for this is so that we can configure HTTPS and go through the steps in more detail.  Plus we get to use our own naming convention rather than Microsoft’s!

Select Application Gateway > Frontend Listeners and enter out configuration details, which are:

  • Name 443_Listener
  • Front End Port Name 443_Port
  • Port 443
  • Protocol HTTPS

We now need our certificate in PFX format, so time to grab that before we move on.

The screenshot below shows the deployed configuration.

WAF 04

HTTP Settings

To ensure that we receive end to end SSL, we need to use a HTTPS setting under HTTP settings (I’m sure Microsoft could come up with a better name).   The HTTP setting which is the backend needs to be trusted by the Frontend, to do this we need to take our original certificate which was .pfx and make sure it’s .cer format.

Select Application Gateway > HTTP Settings and enter out configuration details, which are:

  • Name 443_Setting
  • Request Timeout: 30
  • Cookie Based Affinity: Enabled
  • Port 443

The configuration should look something like the screenshot below.

WAF 05

Rule

Next we are going to configure a Rule (which we are going to change, but we have to do things in a certain order).

Select Application Gateway > Rules and enter out configuration details, which are:

  • Name 443_Rule
  • Listener 443_Listener
  • HTTP Setting 443_Setting

WAF 06

Now we are cooking on gas and we can remove the default settings.

Remove Default Settings

Lets start with Rules, select ‘Rule1’ and click delete.  Once that has gone, select Listeners and then AppGatewayHTTPListener and click delete.  You will be prompted to confirm that it will make changes to the FrontEndIP and Port, which makes sense as it will no longer listen on Port 80.

Then last of all select HTTP Settings and then appGatewayBackendHttpSettings and click delete.

Sense Check

Right before we go any further we are going to perform a Backend Health Check to see what is occurring.

WAF 07

Man down, I repeat man down!  The reason for this is that the Application Gateway requires specific ports to be opened up for the Health Check API to work which are 65503-65534

I usually apply NSG to subnets as it makes all resources placed within the subnet then inherit the security rules.

As you can see I have created two rules, the first allows HTTPS traffic from the internet and the second allows the Health Check API inbound ports.

WAF09

If this was a production rollout of a WAF with AD FS I would strongly suggest you create some specific rules to limit traffic flow between subnets within the vNET.  As this is a lab environment which is only up temporarily I shall move on!

Time again for another sense check, lets verify the Backend Health.  Argh, we are still in a man down scenario.

WAF 07

The reason for this is the built-in Application Gateway probes our Web Application Proxies on ports they don’t respond on.  We need to create a Custom Health Probe.

Health Probe

So lets get Backend Health working.  Select Application Gateway > Health Probes > Add.  The configuration details we are going to use are as follows:

  • Name Probe_ADFS
  • Host adfs.vmfocus.com
  • Procotol HTTPS
  • Path /adfs/ls/idpinitiatedsignon.htm
  • Interval 30 Seconds
  • Timeout 30 Seconds
  • Unhealth Threshold 3

It should look like the picture below.

WAF10

Finally we need to apply the Custom Health Prove to our HTTP Setting.  Select HTTP Setting > 443_Setting and Tick ‘Use Custom Probe’ > Select Probe_ADFS.

WAF11

Now lets check the Backend Health one last time.

WAF12

Excellent the Application Gateway will now be passing traffic correctly to our Web Application Proxies.  All we need to do now is update DNS to point to the Public IP Address of the Application Gateway.

 

Part 1 – Configuring Azure Application Gateways with AD FS

This is the first in a short series of blog post which is aimed at the configuration of an Azure Application Gateways.

Why might you ask am I creating a blog post series? For two reasons, firstly I think that the Application Gateway provides an extra level of protection for internet facing applications and secondly I found the Microsoft documentation lacking in a few areas.

What is an Application Gateway?

Application Gateways are a dedicated virtual appliance providing application delivery controller services.

Benefits of using Application Gateway are:

  • Provides Layer 7 load balancing and routing
  • SSL Offload, taking the burden of decrypting traffic from Internet facing servers onto the Application Gateway
  • End to End Encryption by terminating SSL connection onto the Application Gateway, applies routing rules and then re-encrypts traffic
  • Cookie Based Session Affinity to ensure users are directed back to the same session
  • Protects web applications from common attack scenarios such as cross-site scripting, SQL injection and session hijacks using web application firewall capabilities
  • Custom health probes enabling specific application paths to be monitored

Drawbacks of using Application Gateway are:

  • Increased complexity versus Load Balancers
  • Can only be deployed when it is the first resource within a subnet

In this scenario I have AD FS running on Windows 2016 which is running on Microsoft Azure and is integrated with Azure AD via Azure AD Connect.  A logical overview of the configuration is shown below.

Azure AD FS v0.1.png

The plan is to extend this design and include an Application Gateway running Web Application Firewall functionality.  A logical configuration of the desired state is shown below.

Azure AD FS WAF v0.1.png

Before we being, I recommend that you verify your AD FS configuration to make sure it’s functioning correctly.  Also you will need your AD FS certificate available in order to undertake the SSL Offload onto the Application Gateway.

Getting Everything Ready

I know you are itching to crack on, but I try and work in a logical order.  So first of all make sure you have your subnets defined correctly in Azure.  The configuration I’m using is as follows:

VMF-WE-SUB01

172.16.1.0/24 – This subnet is the Trusted Network in the diagram above.

VMF-WE-SUB02

172.16.2.0/24 – This subnet is the DMZ Internal Network in the diagram above.

VMF-WE-SUB03

172.16.3.0/24 – This subnet is the DMZ External Network in the diagram above and will be used for the Application Gateway

Important, the Application Gateway must be the first resource deployed in a newly created subnet

WAP Servers

We need to get the thumbprint for our AD FS Certificate and ensure this is bound correctly.  Run the following command to obtain the Certificate Hash and Application ID

netsh http show sslcert

WAF08

Next we need to run the command on both WAP servers

netsh http add sslcert ipport=0.0.0.0:443 certhash=f2d9bb93d29a2c2c0835f4a4cb2d67d51efc5706 appid={5d89a20c-beab-4389-9447-324788eb944a}

To verify the command has ran correctly, view your SSL Certificates again and you should see IP:Port 0.0.0.0:443 tied to your AD FS Certificate.

WAF09

Deploy Application Gateway

Within the freshly created VMF-WE-SUB03 we are going to deploy an Application Gateway.

Let’s start by entering the basics, I calling mine an imaginative VMF-WE-AG01.  It’s going to be a WAF, so I have selected this.  Finally, I will be using an existing Resource Group.

WAF 01

The VNet is VMF-WE-VNET01 and the subnet is VMF-WE-SUB03.  We are gong tro create a Static Public IP Address (I’m calling mine VMF-WE-AG01-PIP).  Finally we will leave the Listener Configuration as HTTP for now.

WAF 02

That’s the Application Gateway deployment beginning.  It’s going to take a while so suggest you make a brew and get yourself ready for the next instalment.