π Add HTTPS with Azure Application Gateway (End-to-End)¶
What youβll build now¶



π§ Key Concepts (Understand First)¶
| Component | Purpose |
|---|---|
| Application Gateway | Layer-7 (HTTP/HTTPS) load balancer |
| HTTPS (443) | Secure traffic from users |
| SSL Termination | TLS ends at App Gateway |
| Backend Pool | Your VM Scale Set |
| Listener | Port + protocol (443/HTTPS) |
| Rule | Listener β Backend mapping |
π TLS terminates at App Gateway, backend stays HTTP (simpler & common).
1οΈβ£ Prerequisites (Checklist)¶
You already have:
- β VM Scale Set running Nginx
- β HTTP working via Load Balancer
You now need:
- π SSL certificate (
.pfx) - π (Optional but recommended) Domain name
2οΈβ£ Create / Get SSL Certificate¶
Option A: Self-Signed (Learning / Testing)¶
Convert to .pfx:
π Remember the password you set.
Option B: Production (Recommended)¶
- Use Letβs Encrypt
- Or buy cert from CA
- Upload
.pfx(same process)
3οΈβ£ Create Application Gateway Subnet¶
β οΈ Application Gateway must have its own subnet.
az network vnet create \
--resource-group rg-azure-vm \
--name appgw-vnet \
--address-prefix 10.0.0.0/16 \
--subnet-name appgw-subnet \
--subnet-prefix 10.0.1.0/24
4οΈβ£ Create Public IP for Application Gateway¶
az network public-ip create \
--resource-group rg-azure-vm \
--name appgw-public-ip \
--sku Standard \
--allocation-method Static
5οΈβ£ Create Application Gateway¶


az network application-gateway create \
--resource-group rg-azure-vm \
--name app-gateway \
--sku Standard_v2 \
--capacity 2 \
--vnet-name appgw-vnet \
--subnet appgw-subnet \
--public-ip-address appgw-public-ip \
--http-settings-port 80 \
--http-settings-protocol Http \
--frontend-port 80
βοΈ App Gateway is now running (HTTP only for now)
6οΈβ£ Upload SSL Certificate to App Gateway¶
az network application-gateway ssl-cert create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name appgw-ssl-cert \
--cert-file appgw.pfx \
--cert-password "<PFX_PASSWORD>"
7οΈβ£ Create HTTPS Listener (Port 443)¶
az network application-gateway frontend-port create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name https-port \
--port 443
az network application-gateway http-listener create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name https-listener \
--frontend-port https-port \
--ssl-cert appgw-ssl-cert
8οΈβ£ Attach VM Scale Set as Backend Pool¶
az network application-gateway address-pool create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name vmss-backend-pool
Associate VMSS:
az vmss update \
--resource-group rg-azure-vm \
--name web-vmss \
--set virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].applicationGatewayBackendAddressPools='[{"id":"/subscriptions/<SUB_ID>/resourceGroups/rg-azure-vm/providers/Microsoft.Network/applicationGateways/app-gateway/backendAddressPools/vmss-backend-pool"}]'
9οΈβ£ Create HTTPS Routing Rule¶
az network application-gateway rule create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name https-rule \
--http-listener https-listener \
--rule-type Basic \
--address-pool vmss-backend-pool \
--http-settings appGatewayBackendHttpSettings
π (Optional but Best Practice) HTTP β HTTPS Redirect¶
az network application-gateway redirect-config create \
--resource-group rg-azure-vm \
--gateway-name app-gateway \
--name http-to-https \
--type Permanent \
--target-listener https-listener
π Test HTTPS¶
Get public IP:
az network public-ip show \
--resource-group rg-azure-vm \
--name appgw-public-ip \
--query ipAddress -o tsv
Open:
βοΈ HTTPS works βοΈ SSL terminated at App Gateway βοΈ Traffic forwarded to VMSS
π Security Flow (Very Important)¶
User
βββ HTTPS (443)
βββ Application Gateway
βββ HTTP (80)
βββ VM Scale Set (Nginx)
Why this is good¶
- Cert managed in one place
- Backend stays simple
- Scales automatically
- Easy rotation of SSL certs
β What You Achieved (Production-Level)¶
β Layer-7 load balancing β HTTPS termination β Secure public endpoint β VMSS backend β Ready for autoscaling + rolling updates