Hello

Havent been here in a while but might as well give it a shot.

I have several Apache Tomcat instances running on a Windows Server on different ports. They are all HTTP. The idea would be to (on the same server) install a IIS and use it a content switcher and also as a SSL terminator.

This was depending on the URL, the IIS would redirect to one spot or another.

All of this is to replace a Netscaler

Ive tried to setup this with ARR, URL rewrite and IIS but for now Im only getting a "Bad Gateway" error.

Anyone done this before?

IIS should be able to do this just fine - "Bad Gateway" actually has a lot of different subcategories in IIS, so the first thing is to figure out which of those sub categories this falls into. This can sometimes be defined on the error pages if they are enabled.

Connection Timeout - This is generally the most common and usually has to do with something like a firewall on the host. you can enable failed request tracing to track this down

Connection Terminated - This is generally caused when the remote endpoint doesn't get sent the right HTTP headers, and will prematurely close the connection, this should be very visible inside the tomcat logs if that is the case.

No Route - This can happen when using things on multiple subnets or containers on the same server, sometimes there won't be routes (or reverse routes) that allow communication between the containers and/or the other ips.

I think tomcat logs are probably the first place to look to see if connections are even making it there, and if not, then follow up on IIS logs/event viewer to see why not.

If you have tomcat listening on different ports (eg. 8081, 8082, etc.) your rewrite should look like this

<rewrite>
    <rules>
        <rule name="Reverse Proxy to tomcat1" stopProcessing="true">
            <match url="^tomcat1/(.*)" />
            <action type="Rewrite" url="http://localhost:8081/{R:1}" />
        </rule>
        <rule name="Reverse Proxy to tomcat2" stopProcessing="true">
            <match url="^tomcat2/(.*)" />
            <action type="Rewrite" url="http://localhost:8082/{R:1}" />
        </rule>
    </rules>
</rewrite>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.