Atmosphere 2.1.2 + apache 2.4.6 with mod_proxy_ajp cannot forward request to Tomcat 7

370 Views Asked by At

I have Apache 2.4 with mod_proxy_ajp to forward REST requests to Tomcat 7. Everything works fine except that I am using Atmosphere 2.1.2 and the Atmosphere calls do not make it to Tomcat. I know that there are alternatives to Apache for working with websockets (Nginx and HAProxy etc) but I was wondering if there is a way to make it work with Apache? Here is my VirtualHost definition in httpd.conf

<VirtualHost *:80>
    ServerName 192.168.0.100
    ProxyPass /roomky ajp://192.168.0.100:8009/roomky
    ProxyPassReverse /roomky ajp://192.168.0.100:8009/roomky/
    ProxyRequests On
    ProxyVia On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
</VirtualHost>

Any suggestions?

1

There are 1 best solutions below

0
On

In Apache:

  1. You must to add mod_proxy_wstunnel (also requires mod_proxy)
  2. Add proxy rules with the correct websocket (WS, not AJP) protocol:
    • ProxyPass /roomky ws://localhost:8080/roomky
    • ProxyPassReverse /roomky ws://localhost:8080/roomky

In Tomcat:

1.- Declare a NIO Connector in $CATALINA_HOME/conf/server.xml

<Connector 
    protocol="org.apache.coyote.http11.Http11NioProtocol"
    port="8080"
    ...
"/>

Restart both servers and test it again!