【发布时间】:2017-04-07 19:46:37
【问题描述】:
我编写了一个 ASP.NET Web API,它基本上是一个 API 网关。网关的基本 URL 是 http://localhost:88/ApiGateway。我实现的服务会查找一些标头值和 cookie 以路由请求。目前我将它用于蓝绿部署。
当找到具有特定 API-ID 的标头或 cookie 时,会将请求路由到相应的 API。
例如,如果找到的 API-ID 是 alpha-v1.7.4,而 URL 是 http://localhost:88/gateway/app/login.html,则请求将路由到实际应用或网站所在的 http://localhost:8080/app/alpha-v1.7.4/app/login.html。
这在使用 OWIN 和 Katana 时非常有效。所有 URL 均已正确路由。
在 IIS 中安装网关时,事情变得很奇怪。
我已经在网关中添加了一个非常详细的日志记录,该网关记录了每个请求和找到的路由。在 IIS 上,我观察到以下请求正在到达网关并正确路由:
1: http://localhost:88/gateway/app/some_directory/
2: http://localhost:88/gateway/app/another_directory_with_a.dot/
3: http://localhost:88/gateway/app/some_path_no_trailing_slash
以下请求不会到达网关:
4: http://localhost:88/gateway/app/no_trailing_slash_with_a.dot
5: http://localhost:88/gateway/app/index.html
在我看来,IIS 似乎允许传递任何 directory 路径(即带有像 .../.../directory/ 这样的斜杠)、所有 resource 路径(即没有尾随斜杠像.../.../resource),它闻起来不像文件(因为它们没有点),但会阻止没有尾部斜杠但内部有一个点的路径(.../.../may_be_a.file 被阻止,但 .../.../not_a.file/ 通过)。
按照这些说明对我不起作用:How to disable Request Filtering for a specific website on IIS 7.5?
知道如何配置 IIS 以使其正常工作吗?
【问题讨论】:
-
我不知道您是如何进行重定向的。但也许你需要RAMFAR它。
-
@mason:RAMMFAR 对我不起作用——不知道为什么,但我想出了一个不同的解决方案。
标签: asp.net rest iis asp.net-web-api iis-8