I had worked on WebSockets, embedded within a J2EE (Hibernate, …) app under Wildfly. For multiple purposes, some servers I deployed the app run both Nginx or Apache2. Pxoxying both app and websocket with Nginx was quite easy and quick (I’ll detailed the configuration in another post, one day soon), but definitively, I struggle couple of hours with Apache 2.4.
I will NOT cover Socket.IO configuration for Apache 2.4, this is not the point; I focus entirely on real WebSockets.
How does it work with Apache 2.4:
- Enable proxy modules:
a2enmod proxy proxy_http proxy_wstunnel
- If “/app” is the wildfly endpoint for your application server under wildfly, and “/app/ws” is the one for websocket (still under wildfly), add the following lines in the VirtualHost configuration (http or https):
# Please respect the order, otherwise, it won't work # the WebSocket Proxying ProxyRequests Off ProxyPass "/app/ws" "ws://localhost:3000/app/ws" # the common app proxying ProxyPass "/app" "http://localhost:3000/app" ProxyPassReverse "/app" "http://localhost:8080/app"
- Reload Apache 2.4 configuration
service apache2 reload
That’s it, it should work.