'URL encode/decode issue - Jenkins and reverse proxy with IIS(rewrite)

I have using reverse proxy(via ARR). I have following rule setup in web.config.

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse proxy for jenkins" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(http?)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://localhost:8080/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I get following error while browsing this url. http:// jenkins.mytest.com/user/dmn%5Cmda

HTTP ERROR 404 Not Found
URI:    /user/dmn/mda
STATUS: 404
MESSAGE:    Not Found
SERVLET:    Stapler
  • dmn-domain
  • mda-username

whereAs without domain(and slash) in URL it works well. As following

i.e http:// jenkins.mytest.com/user/mda



Solution 1:[1]

I have the following configuration for IIS precisely and it has worked for me, let me know if it is useful to you.

<configuration>
    <system.webServer>
        <rewrite>
            <rules useOriginalURLEncoding="false">
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="{C:1}://mydomain.com:8088{UNENCODED_URL}" appendQueryString="false" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(http|ws)://" />
                    </conditions>
                    <serverVariables>
                        <set name="HTTP_FORWARDED" value="for={REMOTE_ADDR};by={LOCAL_ADDR};host=&quot;{HTTP_HOST}&quot;;proto=&quot;http&quot;" />
                    </serverVariables>
                </rule>
            </rules>
        </rewrite>
        <security>
            <requestFiltering allowDoubleEscaping="true" />
        </security>
    </system.webServer>
</configuration>

Additionally as a guide: https://www.jenkins.io/doc/book/system-administration/reverse-proxy-configuration-iis/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jarvars