ProxyPass a WebSocket connection to a UNIX socket

apache-2.4proxypassreverse-proxysocketwebsocket

In Apache 2.4 you can reverse proxy an HTTP connection to a local Unix socket with: [1]

ProxyPass unix:/path/to/app.sock|http://example.com/app/name

You can reverse proxy a WebSocket connection to a local TCP socket with: [2]

ProxyPass ws://127.0.0.1:12345/app/name

But how can you reverse proxy a WebSocket connection to a Unix socket? [☹]

Best Answer

Ok I got it, once you have mod_proxy and mod_proxy_wstunnel enabled you can do this:

ProxyPass /ws/ unix:/path/to/app.sock|ws://example.com/ws/

It works well for me since I only expect to establish a ws connection on the /ws endpoint.

Related Topic