مشاركة عبر


نشر بوابة تطبيق Azure باستخدام mTLS passthrough listener

تظهر هذه البداية السريعة كيفية نشر بوابة تطبيق Azure مع تمرير TLS (mTLS) المتبادل باستخدام قالب ARM وإصدار 2025-03-01API. في وضع التمرير، تطلب البوابة شهادة عميل لكنها لا تحقق منها. يتم التحقق من صحة الشهادات وتنفيذ السياسات في الخلفية.

الميزات الرئيسية

  • ربط ملف SSL مع المستمع لتمرير mTLS.
  • لا حاجة لشهادة CA للعميل عند البوابة.
  • verifyClientAuthMode يدعم Strict و Passthrough.

إشعار

دعم Portal وPowerShell وCLI لتكوين passthrough غير متوفر حاليا. لغرض هذا الدليل، استخدم قوالب ARM.

Prerequisites

  • اشتراك Azure ومجموعة الموارد.
  • Azure CLI مُثبت.
  • شهادة SSL (PFX مشفر في Base64) وكلمة مرور.
  • مفتاح SSH لإدارة أجهزة لينكس الافتراضية (إذا كان ذلك ممكنا).
  • إصدار 2025-03-01 API لخاصية passthrough.

نشر بوابة التطبيق باستخدام مستمع تمرير mTLS

يقوم هذا القالب بإنشاء ما يلي:

  • شبكة افتراضية تحتوي على شبكتين فرعيتين (واحدة مفوضة لبوابة التطبيقات).
  • عنوان IP عام لواجهة البوابة.
  • بوابة التطبيقات (Standard_v2) مع:
    • شهادة SSL وملف SSL لتمرير شهادة العميل.
    • قاعدة المستمع والتوجيه في HTTPS.
    • تجمع الخلفية يشير إلى خدمة تطبيق. يرجى تحديث القالب بتفاصيل التكوين الخاصة بك وإضافة شهادة SSL صالحة.

ملف المعلمة: deploymentParameters.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "addressPrefix": {
            "value": "10.0.0.0/16"
        },
        "subnetPrefix": {
            "value": "10.0.0.0/24"
        },
        "skuName": {
            "value": "Standard_v2"
        },
        "capacity": {
            "value": 2
        },
        "adminUsername": {
            "value": "ubuntu"
        },
        "adminSSHKey": {
            "value": "<your-ssh-public-key>"
        },
        "certData": {
            "value": "<Base64-encoded-PFX-data>"
        },
        "certPassword": {
            "value": "<certificate-password>"
        }
    }
}

ملف القالب: deploymentTemplate.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "addressPrefix": {
            "defaultValue": "10.0.0.0/16",
            "type": "String",
            "metadata": {
                "description": "Address prefix for the Virtual Network"
            }
        },
        "subnetPrefix": {
            "defaultValue": "10.0.0.0/24",
            "type": "String",
            "metadata": {
                "description": "Subnet prefix"
            }
        },
        "skuName": {
            "defaultValue": "Standard_Medium",
            "type": "String",
            "metadata": {
                "description": "Sku Name"
            }
        },
        "capacity": {
            "defaultValue": 2,
            "type": "Int",
            "metadata": {
                "description": "Number of instances"
            }
        },
        "adminUsername": {
            "type": "String"
        },
		"adminSSHKey": {
            "type": "securestring"
        },
        "certData": {
            "type": "String",
            "metadata": {
                "description": "ssl cert data"
            }
        },
        "certPassword": {
            "type": "SecureString",
            "metadata": {
                "description": "ssl cert password"
            }
        }
    },
    "variables": {
        "applicationGatewayName": "mtlsAppGw",
        "idName": "identity",
        "publicIPAddressName": "mtlsPip",
        "virtualNetworkName": "mtlsVnet",
        "subnetName": "appgwsubnet",
        "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
        "publicIPRef": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]",
        "applicationGatewayID": "[resourceId('Microsoft.Network/applicationGateways',variables('applicationGatewayName'))]",
        "apiVersion": "2025-03-01",
        "identityID": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('idName'))]",
        "backendSubnetId": "[concat(variables('vnetID'),'/subnets/backendsubnet')]"
    },
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[variables('virtualNetworkName')]",
            "apiVersion": "2024-07-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[parameters('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('subnetName')]",
                        "properties": {
                            "addressPrefix": "[parameters('subnetPrefix')]",
                             "delegations": [
                                {
                                    "name": "Microsoft.Network/applicationGateways",
                                    "properties": {
                                        "serviceName": "Microsoft.Network/applicationGateways"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "name": "backendSubnet",
                        "properties": {
                            "addressPrefix": "10.0.2.0/24"
                        }
                    }
                ]
            }
        },
        {
            "type": "Microsoft.Network/publicIPAddresses",
            "sku": {
                "name": "Standard"
            },
            "name": "[variables('publicIPAddressName')]",
            "apiVersion": "2024-07-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "publicIPAllocationMethod": "Static"
            }
        },
        {
            "type": "Microsoft.Network/applicationGateways",
            "name": "[variables('applicationGatewayName')]",
            "apiVersion": "[variables('apiVersion')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "sku": {
                    "name": "Standard_v2",
                    "tier": "Standard_v2",
                    "capacity": 3
                },
                "sslCertificates": [
                    {
                        "name": "sslCert",
                        "properties": {
                            "data": "[parameters('certData')]",
                            "password": "[parameters('certPassword')]"
                        }
                    }
                ],
                "sslPolicy": {
                    "policyType": "Predefined",
                    "policyName": "AppGwSslPolicy20220101"
                },
                "sslProfiles": [
                    {
                        "name": "sslnotrustedcert",
                        "id": "[concat(resourceId('Microsoft.Network/applicationGateways',  variables('applicationGatewayName')), '/sslProfiles/sslnotrustedcert')]",
                        "properties": {
                            "clientAuthConfiguration": {
                                "VerifyClientCertIssuerDN": false,
                                "VerifyClientRevocation": "None",
                                "VerifyClientAuthMode": "Passthrough"
                            }
                        }
                    }                   
                ],
                "gatewayIPConfigurations": [
                    {
                        "name": "appGatewayIpConfig",
                        "properties": {
                            "subnet": {
                                "id": "[variables('subnetRef')]"
                            }
                        }
                    }
                ],
                "frontendIPConfigurations": [
                    {
                        "name": "appGatewayFrontendIP",
                        "properties": {
                            "PublicIPAddress": {
                                "id": "[variables('publicIPRef')]"
                            }
                        }
                    }
                ],
                "frontendPorts": [
                    {
                        "name": "port2",
                        "properties": {
                            "Port": 444
                        }
                    }
                ],
                "backendAddressPools": [
                    {
                        "name": "pool2",
                        "properties": {
                            "BackendAddresses": [
							  {
                                "fqdn": "headerappgw-hsa5gjh8fpfebcfd.westus-01.azurewebsites.net"
                              }
							]
                        }
                    }
                ],
                "backendHttpSettingsCollection": [
                    {
                        "name": "settings2",
                        "properties": {
                            "Port": 80,
                            "Protocol": "Http"
                        }
                    }
                ],
                "httpListeners": [
                    {
                        "name": "listener2",
                        "properties": {
                            "FrontendIPConfiguration": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendIPConfigurations/appGatewayFrontendIP')]"
                            },
                            "FrontendPort": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendPorts/port2')]"
                            },
                            "Protocol": "Https",
                            "SslCertificate": {
                                "Id": "[concat(variables('applicationGatewayID'), '/sslCertificates/sslCert')]"
                            },
                            "sslProfile": {
                                "id": "[concat(variables('applicationGatewayID'), '/sslProfiles/sslnotrustedcert')]"
                            }
                        }
                    }
                ],
                "requestRoutingRules": [
                    {
                        "Name": "rule2",
                        "properties": {
                            "RuleType": "Basic",
                            "priority": 2000,
                            "httpListener": {
                                "id": "[concat(variables('applicationGatewayID'), '/httpListeners/listener2')]"
                            },
                            "backendAddressPool": {
                                "id": "[concat(variables('applicationGatewayID'), '/backendAddressPools/pool2')]"
                            },
                            "backendHttpSettings": {
                                "id": "[concat(variables('applicationGatewayID'), '/backendHttpSettingsCollection/settings2')]"
                            }
                        }
                    }
                ]
            },
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
                "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
            ]
        }
    ]
}

نشر القالب

az deployment group create \
  --resource-group <your-resource-group> \
  --template-file deploymentTemplate.json \
  --parameters @deploymentParameters.json

التحقق من الصحة والاختبار

التحقق من النشر

  • في Azure portal، تحقق من ملف JSON الخاص بresource Application Gateway
  • اختر إصدار API 2025-03-01 وتحقق من ملف ملف sslprofile
  • تم ضبط التحقق من صحتها verifyClientAuthMode على "تمرير"
"sslProfiles": [
         {
             "name": "sslnotrustedcert",
             "id": "samplesubscriptionid",
             "etag": "W/\"851e4e20-d2b1-4338-9135-e0beac11aa0e\"",
             "properties": {
                 "provisioningState": "Succeeded",
                 "clientAuthConfiguration": {
                     "verifyClientCertIssuerDN": false,
                     "verifyClientRevocation": "None",
                     "verifyClientAuthMode": "Passthrough"
                 },
                 "httpListeners": [
                     {
                         "id": "samplesubscriptionid"
                     }
                 ]

إرسال شهادة العميل إلى الخلفية

  • إذا كنت بحاجة إلى إعادة توجيه شهادة العميل إلى الخلفية، قم بتكوين قاعدة إعادة كتابة كما هو موضح في متغيرات خادم المصادقة المتبادلة.

  • إذا أرسل العميل شهادة، فإن إعادة الكتابة تضمن تضمين شهادة العميل في رؤوس الطلبات لمعالجة الواجهة الخلفية.

الاتصال التجريبي

  • يجب إنشاء روابط حتى لو لم يتم تقديم شهادة عميل.

معلمات مرور mTLS

Name Type وصف
تحقق منClientCertIssuerDN boolean تحقق من اسم مصدر شهادة العميل على البوابة
التحقق منClientRevocation options تحقق من إلغاء شهادة العميل
VerifyClientAuthMode options تعيين وضع شهادة العميل (Strict أو Passthrough)

وضع التمرير: تطلب البوابة شهادة عميل لكنها لا تنفذها. الواجهة الخلفية تتحقق من صحة الشهادة وتفرض السياسة.

إشعار أمني

يصنف هذا الحل ضمن مايكروسوفت كونفيدنيشال. يرجى التأكد من اتباع أفضل ممارسات الأمان والتعامل مع البيانات في مؤسستك عند نشر وإدارة هذا الحل.