question

JeffPhillips-0195 avatar image
0 Votes"
JeffPhillips-0195 asked BruceZhang-MSFT commented

IIS ISAPI Redirect using Relative not Absolute URL

I'm using IIS as the frontend for a tomcat process running my CA service. An ISAPI redirect is used to pass the queries to the tomcat workers matching the URL /csrscep/... In our lab we have two devices from different vendors, the first works fine and uses HTTP/1.1 and a relative URI in the GET method:
GET /csrscep/123?operation=GetCACert&message=GetCACert HTTP/1.1 HOST=192.168.111.211

The non-working device uses HTTP/1.0 and an absolute URI in the GET method:
GET http://192.168.111.221/123?operation=GetCACert&message=GetCACert HTTP/1.0

For the first device the isapi handler passes the RequestURL=/csrscep/123 and the tomcat workermapper.properties correctly maps to the worker for /csrcsep

For the second device the isapi handler passes the RequestURL=http://192.168.111.221/123 which causes tomcat to report the error "URI does not begin with '/'" which is the result of the tomcat normalize servlet.

It's not possible to change the request behavior of the second device so I was trying to find a way to rewrite the RequestURL that is passed to the ISAPI Redirect handler but have not had any success. URL Rewrite looks only at the portion after the '/' so I tried to make a generic match all "(^.*)" pattern to match all URLs and rewrite the same value "{R:0}" hoping that it would recraft the RequestURL. This doesn't seem to be the case and looking at the failedRequest tracing log I surmise that the IIS processes are correctly parsing out the relative URI but passing the original absoluteURI to the isapi redirect module.

Any suggestions on how to rewrite the request prior to the isapi redirect module to correct the observed behavior?

Thanks
Jeff

windows-server-iisdotnet-aspnet-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Here's a copy of the failed request tracking log, you can see that in some areas the RequestURL begins with '/' but when it starts a child process the RequestURL is http://192.168.111.211/..."

137728-fr000088.xml


0 Votes 0 ·
fr000088.xml (238.5 KiB)

Hi @JeffPhillips-0195 ,

URL Rewrite looks only at the portion after the '/'

This is by design, URL rewriting will only match the URI part. If you change the host name, port or http, it is matched by the server variable in the condition. URL rewriting cannot rewrite absolute URLs to relative URLs.

Assuming that URL is http://example.com/abc/xyz. {R:0} means abc/xyz, (^.*) will match abc/xyz, not include http://example.com. All rewrite actions base on the host name even if you don't enter the full URL in action. URL rewriting will automatically complete the hostname



0 Votes 0 ·

0 Answers