tomcatiisapache-tomeehttpplatformhandler

how to use httpPlatformHandler with Tomcat on Virtual Directory only


I host a webapp on TomEE and want it available from a front-end IIS Server (same server).

My server is built this way :

I need to access to MyApp with an URL like https://myserver.mydomain.tld/myapp/, but that doesn't work right now, Tomcat isn't even starting, I get a 502.3 Bad Gateway error.

I put this web.config file under "C:\tomee\iis_virtual_directory" :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
        </handlers>
        <httpPlatform processPath="C:\tomee\apache-tomee-9.1.1-microprofile\\bin\startup.bat" arguments="start" stdoutLogEnabled="true" stdoutLogFile="C:\tomee\iis_virtual_directory\log.txt">
            <environmentVariables>
                <environmentVariable name="JRE_HOME" value="C:\tomee\jdk-11.0.18+10" />
                <environmentVariable name="CATALINA_HOME" value="C:\tomee\apache-tomee-9.1.1-microprofile" />
                <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%" />
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>

I also updated below attribute in TomEE server.xml

<Server port="-1" shutdown="SHUTDOWN">
<Connector port="${port.http}" protocol="HTTP/1.1">

I managed to get it working only when I put these web.config parameters inside the main web.config file in c:\inetpub\wwwroot, but then the main ASP.Net app wasn't available anymore.

Then i changed path attribute this way :

<add name="httpplatformhandler" path="myapp/*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />

And both apps are available. But I wonder : what am I missing ? why can't i use a web.config file inside Virtual Directory ? At this point the Virtual Directory is useless and I can delete it without breaking access to MyApp.


Solution

  • Thanks to Jalpa Panchal comment, i made it work as intended. I converted virtual directory to application in IIS Manager, and voila. Not sure why that didn't work before though.