IIS Proxy Re-Encoding URLs Containing Percentage (%)

I am trying to configure a reverse proxy for Jenkins using IIS 7.5, Application Request Routing 3.0 (ARR), and URL Rewrite 2.0.

I have a proxy server that works mostly, but I am facing problems with URLs containing the percent sign (%).

No matter what I try, the proxy insists on either encoding or re-encoding the percent sign in the rewritten URL.

This is how I want the URLs to be rewritten:

http://my.proxy/a%2Fb -> http://my.host:8080/a%2Fb

Here's how the URLs really correspond:

http://my.proxy/a%2Fb -> http://my.host:8080/a/b
- or -
http://my.proxy/a%2Fb -> http://my.host:8080/a%252Fb

How can I get IIS \ ARR \ Rewrite to stop recoding my rewritten URLs?

What I tried:

  • ( URL http://my.host:8080/a/b):

    <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="true" /> <action type="Rewrite" url="http://my.host:8080/{R:1}" /> </rule>

  • UNENCODED_URL ( URL http://my.host:8080/a%252Fb):

    <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{UNENCODED_URL}" pattern="/(.*)" /> </conditions> <action type="Rewrite" url="http://my.host:8080/{C:1}" /> </rule>

  • URL ( - URL http://my.host:8080/a%252Fb):

    <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <action type="Rewrite" url="http://my.host:8080/a%2Fb" /> </rule>

  • Scott Hanselman " Wackiness: , ASP.NET/URL- IIS "

    • <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="*,:,&amp;,\" relaxedUrlToFileSystemMapping="true" />
    • <security> <requestFiltering allowDoubleEscaping="true" /> </security>'

. , IIS - Jenkins, HTTP- URL- .

+4
3

, , , IIS SSL Gerrit. , , , , - , , . , IIS, , , , , ( nr 3, ).

, , IIS, , . , - IIS Gerrit. IIS, 2, %25 URL-. , Gerrit, IIS -. %25 % ( ) Gerrit. . , , - #:

https://gist.github.com/gralin/b5edfd908a41fc7268a7757698af1e66

+2

, url % , , . , URL- .

datatable server-side: true type: GET. url . url, .

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxQueryString="4000" maxUrl="2000" />
        </requestFiltering>
    </security>
    <rewrite>...</rewrite>
    ...
</system.webServer>

, URL- , , .

0

, useOriginalURLEncoding="false":

<rules useOriginalURLEncoding="false">
    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
        <match url="(.*)" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll">
            <add input="{UNENCODED_URL}" pattern="/(.*)" />
        </conditions>
        <action type="Rewrite" url="http://my.host:8080/{C:1}" />
    </rule>
</rules>

. useOriginalURLEncoding .

0

Source: https://habr.com/ru/post/1529907/


All Articles