Search code examples
apachehttpwildfly-8

How to have 2 different web/app servers for the same domain but different context path?


I'm running a standard PHP application on my domain and did set that to www.johndoe.com/p/

Now, the port 80 is apparently serviced by this HTTP server (Apache, not Tomcat). Also, I installed Wildfly 8.2 on this server on port 8000. How, can I use Wildfly WAR applications on the same domain e.g. www.johndoe.com/w/?

I'm positive that there is a way of redirecting the /w/ requests to the Java EE server and keep the /p/ serviced by Apache, right?

I assume mod_proxy (http gateway) and mod_proxy_ajp are simple solutions. Can anyone reflect on my requirements and the the mod_proxy/ajp functionality?

ProxyPass /w ajp://localhost:8000/w
ProxyPassReverse /w http://www.johndoe.com/w

I do not demand load balacing or anything else sophisticated. Just the split of the two contexti. Only port 80 is accessible from the internet.

Thank you.


Solution

  • Okay. Here the resolution.

    I added to Wildfly 8.2 standalone.xml the following ajp-listener...

    <server name="default-server">
        <http-listener name="default" socket-binding="http"/>
        <ajp-listener name="ajp" socket-binding="ajp"/>
        <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
    

    ... and bind it to the socket ...

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:28009}"/>
        <socket-binding name="http" port="${jboss.http.port:28080}"/>
        <socket-binding name="https" port="${jboss.https.port:28443}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="mail.johndoe.com" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
    

    Invoke service wildfly reload or service wildfly restart. To Wildfly listening on AJP requests.

    Finally, add to your http.conf file of your Apache Virtual Host Domain the following:

    ProxyPass /w ajp://127.0.0.1:28009/w
    ProxyPassReverse /w ajp://127.0.0.1:28009/w
    

    Also for Apache, restart with service apache2 reload.

    Caution. In Parallels Plesk, the virtual host config file must be edited in /var/www/vhosts/system/johndoe.com/conf/http.conf and NOT in /var/vhosts/johndoe.com/conf/http.conf