简体   繁体   中英

How to configure IIS application to work as a gateway

I have written an ASP.NET Web API which is basically an API gateway. The base URL of the gateway is http://localhost:88/ApiGateway . The service I have implemented looks up some header values and cookies in order to route a request. Currently I use it for blue-green deployments.

When a header or cookie with a specific API-ID is found, the request is routed to the corresponding API.

For example, if the found API-ID is alpha-v1.7.4 , and the URL is http://localhost:88/gateway/app/login.html , the request is routed to http://localhost:8080/app/alpha-v1.7.4/app/login.html where the actual app or website resides.

This work perfectly when using OWIN and Katana. All URLs are routed correctly.

When installing the gateway in IIS, things are getting strange.

I have put a very verbose logging into the gateway which logs each request and the found route. On IIS I observe that the followings requests are reaching the gateway and are routed properly:

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

The following request do not reach the gateway:

4: http://localhost:88/gateway/app/no_trailing_slash_with_a.dot
5: http://localhost:88/gateway/app/index.html

To me it seems that IIS is letting pass any directory paths (ie with a trainling slash like .../.../directory/ ), all resource path (ie with no trailing slash like .../.../resource ) which do not smell like a file (since they have not dot), but blocks paths which have no trailing slash but a dot inside ( .../.../may_be_a.file is blocked, but .../.../not_a.file/ passes).

Following these instruction did not work for me: How to disable Request Filtering for a specific website on IIS 7.5?

Any idea how to configure IIS to get this to work?

After messing around with RAMMFAR which did not work for me, I came around with this solution:

<system.webServer>
  <handlers>
    <clear />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>
</system.webServer>

Just clearing all handlers and adding the one and only I need solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM