Configure Websocket through Apache2

Hello,

I got a Vaadin App (7.6.1) on a tomcat 8.5.15

Tomcat connectors

 <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
     connectionTimeout="20000"
     redirectPort="8443" />
[/code][code]
 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

How do I get websocket working through an Apache2 (2.4.10) with mod_proxy and mod_proxy_wstunnel?

I tried different approaches I found on the internet, but nothing have worked so far

e.g.

[code]
RewriteEngine on
RewriteCond %{QUERY_STRING} ^((?!X-Atmosphere-Transport=websocket).)*$
RewriteRule ^/PUSH/ http://localhost:8080/MyApp/PUSH/$1 [P]

ProxyPass          /MyApp/PUSH     ws://localhost:8080/MyApp/PUSH
ProxyPassReverse   /MyApp/PUSH     ws://localhost:8080/MyApp/PUSH
ProxyPass          /MyApp/VAADIN   ws://localhost:8080/MyApp/VAADIN
ProxyPassReverse   /MyApp/VAADIN   ws://localhost:8080/MyApp/VAADIN
ProxyPass          /MyApp          ajp://localhost:8009/MyApp

[/code]I get (in apaches error.log)

[proxy:warn] [pid 29724:tid 140011599263488] [client 10.80.3.151:61329] AH01144: No protocol handler was valid for the URL /MyApp/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. Help is much appreciated, thank you

Funny, I was looking for the exact same problem. I have tested several configurations but none helped.

The only difference between your setup and mine is: We use an embedded tomcat (Spring boot) and I want to use wss.

By the way:

This is our setup
Application server:
Vaadin 7.7.6 or 7.7.9 (depending on our internal software release)
Tomcat 8.5.6 or 8.5.14 (depending on our internal software release)
OS: Debian Stretch

Reverse Proxy
Apache 2.4.25
OS: Debian Stretch

apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
headers_module (shared)
http2_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_http_module (shared)
proxy_wstunnel_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_shm_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)

So in my opinion we are good to go…

So yes, help would be very much appreciated. So +1 from us.

Best regards
René

Hi Thomas,

It has been 2 years and I believe that you already solved the issue. I have been pulling my hair for a couple of days to make websocket working. I found a solution [here]
(https://support.plesk.com/hc/en-us/articles/360000739853-Does-Node-js-on-Plesk-Onyx-support-WebSockets-socket-io-) and I would like to share here. It may helps you and the others.

<IfModule mod_proxy_wstunnel.c>
	RewriteEngine on
	RewriteCond %{REQUEST_URI} ^/ [NC]

	RewriteCond %{QUERY_STRING} transport=websocket [NC]

	RewriteRule /(.*) ws://localhost:8080/com.myapp/$1 [P,L]

</IfModule>

Configuration:

  • Httpd: 2.4.6-88.el7.centos
  • Vaadin: 12.0.7
  • WildFly: 15.0.1.final