HTTP to HTTPS redirection in portal - Azure Application Gateway (2024)

  • Article

You can use the Azure portal to create an application gateway with a certificate for TLS termination. A routing rule is used to redirect HTTP traffic to the HTTPS port in your application gateway. In this example, you also create a virtual machine scale set for the backend pool of the application gateway that contains two virtual machine instances.

In this article, you learn how to:

  • Create a self-signed certificate
  • Set up a network
  • Create an application gateway with the certificate
  • Add a listener and redirection rule
  • Create a virtual machine scale set with the default backend pool

If you don't have an Azure subscription, create a free account before you begin.

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. To get started, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

This tutorial requires the Azure PowerShell module version 1.0.0 or later to create a certificate and install IIS. Run Get-Module -ListAvailable Az to find the version. If you need to upgrade, see Install Azure PowerShell module. To run the commands in this tutorial, you also need to run Login-AzAccount to create a connection with Azure.

Create a self-signed certificate

For production use, you should import a valid certificate signed by a trusted provider. For this tutorial, you create a self-signed certificate using New-SelfSignedCertificate. You can use Export-PfxCertificate with the Thumbprint that was returned to export a pfx file from the certificate.

New-SelfSignedCertificate ` -certstorelocation cert:\localmachine\my ` -dnsname www.contoso.com

You should see something like this result:

PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\myThumbprint Subject---------- -------E1E81C23B3AD33F9B4D1717B20AB65DBB91AC630 CN=www.contoso.com

Use the thumbprint to create the pfx file:

$pwd = ConvertTo-SecureString -String "Azure123456!" -Force -AsPlainTextExport-PfxCertificate ` -cert cert:\localMachine\my\E1E81C23B3AD33F9B4D1717B20AB65DBB91AC630 ` -FilePath c:\appgwcert.pfx ` -Password $pwd

Create an application gateway

A virtual network is needed for communication between the resources that you create. Two subnets are created in this example: one for the application gateway, and the other for the backend servers. You can create a virtual network at the same time that you create the application gateway.

  1. Sign in to the Azure portal.

  2. Click Create a resource found on the upper left-hand corner of the Azure portal.

  3. Select Networking and then select Application Gateway in the Featured list.

  4. Enter these values for the application gateway:

    • myAppGateway - for the name of the application gateway.

    • myResourceGroupAG - for the new resource group.

      HTTP to HTTPS redirection in portal - Azure Application Gateway (1)

  5. Accept the default values for the other settings and then click OK.

  6. Click Choose a virtual network, click Create new, and then enter these values for the virtual network:

    • myVNet - for the name of the virtual network.

    • 10.0.0.0/16 - for the virtual network address space.

    • myAGSubnet - for the subnet name.

    • 10.0.0.0/24 - for the subnet address space.

      HTTP to HTTPS redirection in portal - Azure Application Gateway (2)

  7. Click OK to create the virtual network and subnet.

  8. Under Frontend IP configuration, ensure IP address type is Public, and Create new is selected. Enter myAGPublicIPAddress for the name. Accept the default values for the other settings and then click OK.

  9. Under Listener configuration, select HTTPS, then select Select a file and navigate to the c:\appgwcert.pfx file and select Open.

  10. Type appgwcert for the cert name and Azure123456! for the password.

  11. Leave the Web application firewall disabled, and then select OK.

  12. Review the settings on the summary page, and then select OK to create the network resources and the application gateway. It may take several minutes for the application gateway to be created, wait untilthe deployment finishes successfully before moving on to the next section.

Add a subnet

  1. Select All resources in the left-hand menu, and then select myVNet from the resources list.

  2. Select Subnets, and then click Subnet.

    HTTP to HTTPS redirection in portal - Azure Application Gateway (3)

  3. Type myBackendSubnet for the name of the subnet.

  4. Type 10.0.2.0/24 for the address range, and then select OK.

Add a listener and redirection rule

Add the listener

First, add the listener named myListener for port 80.

  1. Open the myResourceGroupAG resource group and select myAppGateway.
  2. Select Listeners and then select + Basic.
  3. Type MyListener for the name.
  4. Type httpPort for the new frontend port name and 80 for the port.
  5. Ensure the protocol is set to HTTP, and then select OK.

Add a routing rule with a redirection configuration

  1. On myAppGateway, select Rules and then select +Request routing rule.
  2. For the Rule name, type Rule2.
  3. Ensure MyListener is selected for the listener.
  4. Click on Backend targets tab and select Target type as Redirection.
  5. For Redirection type, select Permanent.
  6. For Redirection target, select Listener.
  7. Ensure the Target listener is set to appGatewayHttpListener.
  8. For the Include query string and Include path select Yes.
  9. Select Add.

Note

appGatewayHttpListener is the default listener name. For more information, see Application Gateway listener configuration.

Create a virtual machine scale set

In this example, you create a virtual machine scale set to provide servers for the backend pool in the application gateway.

  1. On the portal upper left corner, select +Create a resource.
  2. Select Compute.
  3. In the search box, type scale set and press Enter.
  4. Select Virtual machine scale set, and then select Create.
  5. For Virtual machine scale set name, type myvmss.
  6. For Operating system disk image, ensure Windows Server 2016 Datacenter is selected.
  7. For Resource group, select myResourceGroupAG.
  8. For User name, type azureuser.
  9. For Password, type Azure123456! and confirm the password.
  10. For Instance count, ensure the value is 2.
  11. For Instance size, select D2s_v3.
  12. Under Networking, ensure Choose Load balancing options is set to Application Gateway.
  13. Ensure Application gateway is set to myAppGateway.
  14. Ensure Subnet is set to myBackendSubnet.
  15. Select Create.

Associate the scale set with the proper backend pool

The virtual machine scale set portal UI creates a new backend pool for the scale set, but you want to associate it with your existing appGatewayBackendPool.

  1. Open the myResourceGroupAg resource group.
  2. Select myAppGateway.
  3. Select Backend pools.
  4. Select myAppGatewaymyvmss.
  5. Select Remove all targets from backend pool.
  6. Select Save.
  7. After this process completes, select the myAppGatewaymyvmss backend pool, select Delete and then OK to confirm.
  8. Select appGatewayBackendPool.
  9. Under Targets, select VMSS.
  10. Under VMSS, select myvmss.
  11. Under Network Interface Configurations, select myvmssNic.
  12. Select Save.

Upgrade the scale set

Finally, you must upgrade the scale set with these changes.

  1. Select the myvmss scale set.
  2. Under Settings, select Instances.
  3. Select both instances, and then select Upgrade.
  4. Select Yes to confirm.
  5. After this completes, go back to the myAppGateway and select Backend pools. You should now see that the appGatewayBackendPool has two targets, and myAppGatewaymyvmss has zero targets.
  6. Select myAppGatewaymyvmss, and then select Delete.
  7. Select OK to confirm.

Install IIS

An easy way to install IIS on the scale set is to use PowerShell. From the portal, click the Cloud Shell icon and ensure that PowerShell is selected.

Paste the following code into the PowerShell window and press Enter.

$publicSettings = @{ "fileUris" = (,"https://raw.githubusercontent.com/Azure/azure-docs-powershell-samples/master/application-gateway/iis/appgatewayurl.ps1"); "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File appgatewayurl.ps1" }$vmss = Get-AzVmss -ResourceGroupName myResourceGroupAG -VMScaleSetName myvmssAdd-AzVmssExtension -VirtualMachineScaleSet $vmss ` -Name "customScript" ` -Publisher "Microsoft.Compute" ` -Type "CustomScriptExtension" ` -TypeHandlerVersion 1.8 ` -Setting $publicSettingsUpdate-AzVmss ` -ResourceGroupName myResourceGroupAG ` -Name myvmss ` -VirtualMachineScaleSet $vmss

Upgrade the scale set

After changing the instances with IIS , you must once again upgrade the scale set with this change.

  1. Select the myvmss scale set.
  2. Under Settings, select Instances.
  3. Select both instances, and then select Upgrade.
  4. Select Yes to confirm.

Test the application gateway

You can get the application public IP address from the application gateway Overview page.

  1. Select myAppGateway.

  2. On the Overview page, note the IP address under Frontend public IP address.

  3. Copy the public IP address, and then paste it into the address bar of your browser. For example, http://52.170.203.149

    HTTP to HTTPS redirection in portal - Azure Application Gateway (4)

  4. To accept the security warning if you used a self-signed certificate, select Details and then Go on to the webpage. Your secured IIS website is then displayed as in the following example:

    HTTP to HTTPS redirection in portal - Azure Application Gateway (5)

Next steps

Learn how to Create an application gateway with internal redirection.

HTTP to HTTPS redirection in portal - Azure Application Gateway (2024)
Top Articles
Study in Dubai 2024: Cost, Admission Process, Eligibility, Visa, Scholarship
Airline Friendly Mobility Scooters - Rules for Flying on a Plane
Fiskars X27 Kloofbijl - 92 cm | bol
Jail Inquiry | Polk County Sheriff's Office
Manhattan Prep Lsat Forum
Algebra Calculator Mathway
What Are the Best Cal State Schools? | BestColleges
T Mobile Rival Crossword Clue
The Realcaca Girl Leaked
Sprague Brook Park Camping Reservations
Tyrunt
Music Archives | Hotel Grand Bach - Hotel GrandBach
biBERK Business Insurance Provides Essential Insights on Liquor Store Risk Management and Insurance Considerations
Items/Tm/Hm cheats for Pokemon FireRed on GBA
Indiana Immediate Care.webpay.md
Jack Daniels Pop Tarts
Classroom 6x: A Game Changer In The Educational Landscape
ocala cars & trucks - by owner - craigslist
Conan Exiles Thrall Master Build: Best Attributes, Armor, Skills, More
Mzinchaleft
All Obituaries | Buie's Funeral Home | Raeford NC funeral home and cremation
Glenda Mitchell Law Firm: Law Firm Profile
Scout Shop Massapequa
Sea To Dallas Google Flights
Anotherdeadfairy
F45 Training O'fallon Il Photos
Sofia the baddie dog
Page 2383 – Christianity Today
Wood Chipper Rental Menards
Radical Red Ability Pill
Hwy 57 Nursery Michie Tn
Rek Funerals
Little Einsteins Transcript
Greyson Alexander Thorn
Nurofen 400mg Tabletten (24 stuks) | De Online Drogist
Mosley Lane Candles
Account Now Login In
Mg Char Grill
Bozjan Platinum Coins
Whas Golf Card
Supermarkt Amsterdam - Openingstijden, Folder met alle Aanbiedingen
How to Draw a Sailboat: 7 Steps (with Pictures) - wikiHow
Keir Starmer looks to Italy on how to stop migrant boats
Clausen's Car Wash
US-amerikanisches Fernsehen 2023 in Deutschland schauen
Is Ameriprise A Pyramid Scheme
Ghareeb Nawaz Texas Menu
Yale College Confidential 2027
Tacos Diego Hugoton Ks
Where and How to Watch Sound of Freedom | Angel Studios
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 5994

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.