如何使用Azure应用程序网关路由到另一个路径? [英] How to route to another path with Azure Application Gateway?

查看:187
本文介绍了如何使用Azure应用程序网关路由到另一个路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Azure Application Gateway将我的Azure Web App服务中的URL路径重定向到另一个URL路径.如何避免重定向以包括原始路径?

I want to redirect a URL-path in my Azure Web App service to another URL-path using Azure Application Gateway. How to avoid redirection to include the original path?

我在Azure中有一个带有两个API的ASP.NET Framework 4.7 Web App服务:

I have an ASP.NET framework 4.7 Web App service in Azure with two APIs:

https://myapp.azurewebsites.net/api/values/{int}        -> respons 200
https://myapp.azurewebsites.net/api/forbidden           -> respons 403

然后我有一个应用程序网关

Then I have an App Gateway

http://myapp.northeurope.cloudapp.azure.com

使用基于路径的路线

http://myapp.northeurope.cloudapp.azure.com -> https://myapp.azurewebsites.net (works ok)

并永久重定向到外部站点"

And a permanent redirect to "external site"

/api/values/* -> http://myapp.northeurope.cloudapp.azure.com/api/forbidden

现在,当我转到路径/api/values/1时,它会将我重定向到/api/forbidden/api/values/1

Now when I go to a path /api/values/1 it redirects me wrong to /api/forbidden/api/values/1

http://myapp.northeurope.cloudapp.azure.com/api/values/1 -> http://myapp.northeurope.cloudapp.azure.com/api/forbidden/api/values/1 !!!

方法重定向包括源路径! 未选中包含路径",并且其配置为灰色.

Means redirection includes the origin path! "Include path" is not checked and greyed-out in configuration.

我只想限制从公共Internet访问某些API路径.

I only want to restrict the access to some API-path from public Internet.

推荐答案

对于include path配置,我认为您可以尝试使用

For the include path configuration, I think you could try to set redirection for the listener with Azure CLI or Azure PowerShell with -IncludePath parameter.

From Redirect to external site in the document, it should have option to disable the include path.

进行此更改后,客户需要创建一个新的重定向 配置对象,它指定目标侦听器或外部对象 需要重定向到的站点. 配置元素也 支持启用附加URI路径和查询字符串到的选项 重定向的网址.您还可以选择重定向的类型. 创建后,此重定向配置将附加到源 通过新规则的侦听器.使用基本规则时,重定向 配置与源侦听器关联,并且是全局的 重定向.使用基于路径的规则时,重定向配置 在URL路径图上定义.因此,它仅适用于特定 网站的路径区域.

With this change, customers need to create a new redirect configuration object, which specifies the target listener or external site to which redirection is desired. The configuration element also supports options to enable appending the URI path and query string to the redirected URL. You can also choose the type of redirection. Once created, this redirect configuration is attached to the source listener via a new rule. When using a basic rule, the redirect configuration is associated with a source listener and is a global redirect. When a path-based rule is used, the redirect configuration is defined on the URL path map. So it only applies to the specific path area of a site.

这篇关于如何使用Azure应用程序网关路由到另一个路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆