Apache websocket setup

Table of Contents

Intro

The need was to make sure that our apache was able to communicate with our Sente1

Apache config

To the apacheconfig, under the :443 section (https)

# Trying websockets here, c/o 
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*)           ws://127.0.0.1:8080/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*)           http://127.0.0.1:8080/$1 [P,L]
# END websockets

Server shell, enabling the apache modules

/sudo:root@devflats:/ $> a2enmod proxy_wstunnel
# Considering dependency proxy for proxy_wstunnel:
# Module proxy already enabled
# Enabling module proxy_wstunnel.
# To activate the new configuration, you need to run:
# systemctl restart apache2!
/sudo:root@devflats:/ $>   systemctl restart apache2

Resources

Footnotes

1 Sente is the premier Web Socket library for Clojure[script]. https://github.com/ptaoussanis/sente

Tory Anderson avatar
Tory Anderson
Full-time Web App Engineer, Digital Humanist, Researcher, Computer Psychologist