There is another approach using the <Location>
blocks to have shorter configurations and more readable.
If you want a frontend webserver with HTTPs support (with Apache HTTPd) to proxy request to an underlying backend webserver in plaintext, here a possibility:
#
# https://example.com/websocket -> [Apache:443] -> Websocket plaintext -> [Backend websocket:9000]
# https://example.com/other-stuff -> [Apache:443] -> HTTP plaintext -> [Backend webserver:8080]
#
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/html
# My application without websocket (if you have that)
<Location />
# This can be a Docker container, PHP-FPM, Tomcat, etc.
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
# Plaintext websockets handled by their dedicated path
<Location /websocket>
ProxyPass ws://localhost:9090/
</Location>
SSLEngine on
SSLCertificateFile ssl/cert.pem # Public Certificate
SSLCertificateKeyFile ssl/key.pem # Private certificate
SSLCertificateChainFile ssl/ca.pem # CA or chain certificate
</VirtualHost>
The example also tried to show how to integrate your HTTP web application with your websocket, since that is a frequent issue.
How and Why it works
Here some reference from official documentation:
When used inside a section, the first argument is omitted and the local directory is obtained from the .
― https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#ProxyPass
Also note that very probably you do not need any ProxyPassReverse
in the websocket location since in theory it does not have sense there.
Also note that usually you just need to write ProxyPass ws://localhost:9090/
and not ProxyPass ws://localhost:9090/websocket
or something, since the backend websocket server usually has no location.
This answer was useful at least in Apache/2.4.6 but probably in other versions.
Troubleshooting
If it does not work, search the errors logs of your Apache HTTPd webserver. This really deserves a dedicated research and cannot be clarified here.
Try to isolate the problem to see if you have a problem with proxies in general, or just with websocket.