我的问题是,如何限制从互联网访问我的 Azure WebApp/WebApi。 例如以下架构:
- 一个 WebApi(后端)
- 一个 Web 应用程序(前端)
用户应该调用 WebApp(前端)的 url,但不应该能够从互联网调用 WebApi 的 url。
好的,我知道我可以通过 web.config 中的 IP 限制来限制 WebApi 中的访问。但是没有其他解决办法吗?
我想到了这样的事情:
Azure WebApi and Firewall 这可能吗?我到底需要什么资源?
最佳答案
the Api should not have an external IP/DNS, deny all request coming from internet
根据您的描述,您不会通过url访问后端的Web api,并且不想在Web api中使用身份验证过滤器。
实际上,您可以配置路由器配置来实现它。 您可以在 Global.asax 中使用以下代码:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
关于Azure WebApi - 无法从互联网访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48783009/