Azure 应用程序网关锁定到应用程序服务的路由

Azure Application Gateway locked down route to app service

我已经设置了带有 Web 应用程序防火墙的 azure 应用程序网关,以将流量路由到 azure 应用程序服务。这需要设置 VPN。我遵循了与此类似的说明:https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-web-app-powershell

但是它没有解释如何仅通过应用程序网关限制到应用程序服务的流量。

如果我进入应用服务网络选项卡,可以选择使用 VNet 集成。我认为这可能是一种通过网关锁定对应用程序服务的访问的方法,但我不能 select 网关 VPN,因为 azure 告诉我 'This virtual network has no gateway'。

那么如何锁定对应用程序服务的访问,以便只有通过网关的流量才能访问它?

So how to I lock down access to the app service so that only traffic which comes through the gateway can access it?

据我了解,您无法使用 Application Gateway. But you could leverage IP and Domain Restrictions for azure web sites for allowing the traffic comes through your application gateway to access your azure web app. Here is a similar 执行任何操作。一个简单的方法是,您可以登录到 Azure 门户,选择您的 Web 应用程序,单击 "SETTING > Networking" 并单击 IP 限制部分下的 配置 IP 限制 以添加您的自定义 IP 限制。

我已将以下内容添加到我的 ARM 模板中以设置 web.config 应用服务:

{
      "type": "Microsoft.Web/sites/config",
      "name": "[variables('website_config')]",
      "apiVersion": "2016-08-01",
     ....
        "ipSecurityRestrictions": [
          {
            "ipAddress": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))).IpAddress]",
            "subnetMask": "255.255.255.255"
          }
          ] 
      },
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', variables('websites_name'))]",
        "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
      ]
     },

资源publicIP地址是网关设置的IP地址

我无法再使用我想要的 url http://.azurewebsites.net 访问应用程序服务。最初,当我访问 public IP 地址时,我收到错误消息:“502 - Web 服务器在充当网关或代理服务器时收到无效响应。”但是过了一会儿它工作正常。

在 Azure 门户中转到 Web 服务的 "Access Restriction"。 然后选择仅从应用程序网关所在的 VNet 和子网访问应用程序。