Issue with IIS Reverse proxy

I have XWiki instance running and I am using IIS as reverse proxy to the tomcat for XWiki. For some urls, I get 500 errors. When I access XWiki direct url, I don’t get that 500. It is certainly IIS rewrite module which does something that I can’t seem to figure out.

Here is one of those urls which throws 500

When I access the same url directly pointing to the tomcat server, it works just fine and produces the response.


My web.config for reverse proxy

<?xml version="1.0" encoding="UTF-8"?>
            <rules useOriginalURLEncoding="false">
                <clear />
                <rule name="Redirect to Https" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{UNENCODED_URL}" pattern="/(.*)" />
                    <action type="Rewrite" url="http://mytomcat_server_fqdn:8080/{C:1}" logRewrittenUrl="false" />
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
            <requestFiltering allowDoubleEscaping="true">
   <requestLimits maxAllowedContentLength="3521478366" />
                    <remove segment="bin" />
  <httpRuntime requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true"/>     
        <authentication mode="Windows" />
        <identity impersonate="false" />

Tomcat server.xml (only modified config sections)

           compressableMimeType= "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript">

<Engine name="Catalina" defaultHost="localhost">
  <Valve className="org.apache.catalina.valves.RemoteIpValve"

Is there anything I am missing? Anything I need to do on IIS or Tomcat side?
Please let me know if any other information needed on installation and something that I can try out.

Not sure if it’ll help you but this is what we found when using IIS as reverse proxy.

Though we weren’t using IIS to do the re-writing and instead used URL Rewrite Filter and it looks like you’ve done the same as us with double escaping and invalid characters.

Do you mind sharing your web.config?
Any other things changed related to reverse proxy in xwiki.config or
I appreciate your response.