![](/img/trans.png)
[英]How to configure IIS Express to debug an application in a subdirectory?
[英]How to configure IIS application to work as a gateway
我写了一个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时,这完美地工作。 所有网址均正确路由。
在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/
的训练斜杠)和所有资源路径(即不带有.../.../resource
尾随斜杠) )闻起来不像文件(因为它们没有点),但是阻止了没有尾部斜杠但内部有点的路径( .../.../may_be_a.file
被阻止,但是.../.../not_a.file/
通过)。
遵循以下说明对我不起作用: 如何在IIS 7.5上为特定网站禁用请求筛选?
任何想法如何配置IIS以使其正常工作?
在弄乱了对我不起作用的RAMMFAR之后,我想到了这个解决方案:
<system.webServer>
<handlers>
<clear />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
只需清除所有处理程序并添加一个处理程序,就可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.