Skip to content

Websocketd behind Apache (2.4.x)

Chris Dickens edited this page Feb 4, 2017 · 1 revision

If using Apache 2.4.x you can use modproxy_wstunnel to configure a path to point to websocketd on the same port as your server.

First, enable modproxy and modproxy_wstunnel in your Apache configuration. For Debian/Ubuntu you can use:

sudo a2enmod proxy
sudo a2enmod proxy_wstunnel

Then, add these lines to your site's configuration

    ProxyRequests Off
    ProxyPass "<path>/" "ws://localhost:<port>/"
    ProxyPassReverse "<path>/" "ws://localhost:<port>/"

Where "path" is the path for the URL (eg. "/ws/app") and "port" is the port the websocketd instance is listening on.

Restart Apache and you should be able to use "ws://your_domain/path" to connect to your application.

If you are using SSL you can add the same lines above to your site configuration but include the line...

SSLProxyEngine On

...before the "ProxyRequests" line. You can then use "wss:" instead of "ws:".

Notes

  • You will not be able to access the development console (--devconsole), you will need to write your own client code for testing.
  • If you didn't have modproxy installed before, you must ensure "ProxyRequests Off" is applied to all hosts - you do not want to be running an open proxy!
  • You can block the port websocketd is running on to external connections via your firewall - useful if you only want access via HTTPS.
Clone this wiki locally