# TODO: Most of this can be scripted.
# TODO: Better handling of external dependencies (websocket_plugin.h).
-# as root
+# ! as root !
+# Perform these steps before installing OpenSRF
+# Be sure to restart the websocket instance after an opensrf re-install
+# just like you would the main apache instance:
+# % /etc/init.d/apache2-websockets restart
# see also /usr/share/doc/apache2/README.multiple-instances
% sh /usr/share/doc/apache2.2-common/examples/setup-instance websockets
-% cp examples/apache2/websockets.conf /etc/apache2-websockets/sites-available/
+# update configs
+% cp examples/apache2/websockets/websockets.conf /etc/apache2-websockets/sites-available/
+% cp examples/apache2/websockets/ports.conf /etc/apache2-websockets/
# activate the websockets configuration
% a2ensite-websockets websockets.conf
% a2dissite-websockets default
# remove most of the mods with this shell script
+# you may have to do this twice, depending on the order in which
+# they are removed. (Some modules rely on other modules).
MODS=$(apache2ctl-websockets -M | grep shared | grep -v 'Syntax OK' | sed 's/_module//g' | cut -d' ' -f2 | xargs);
for mod in $MODS; do
# follow the instructions for installing Apache mod_websockets at
# https://github.com/disconnect/apache-websocket
-# copy the headers into place so OpenSRF can compile
-% cp $LOCATION_OF_APACHE_WEBSOCKET_CHECKOUT/websocket_plugin.h src/gateway/
+# install the apache-websocket module
+% cd tmp # or wherever
+% git clone https://github.com/disconnect/apache-websocket
+% cd apache-websocket
+% apxs2 -i -a -c mod_websocket.c
-# install OpenSRF
+# remove from the main apache instance
+% a2dismod websocket
+# add to the websocket instance
+% a2enmod-websockets websocket
-# remove the websocket module from the default OpenSRF Apache instance
-% a2dismod osrf_websocket_translator
-
-# optional: add these configuration variables to
+# OPTIONAL: add these configuration variables to
# /etc/init.d/apache2-websockets/envvars and adjust as needed.
# export OSRF_WEBSOCKET_IDLE_TIMEOUT=60
# export OSRF_WEBSOCKET_IDLE_CHECK_INTERVAL=5
# After OpenSRF is up and running, fire up the secondary Apache instance
# errors will appear in /var/log/apache2-websockets/error.log
-% /etc/init.d/apache2-websockets restart
+++ /dev/null
-# :vim set syntax apache
-#
-# This is the top-level configuration file for the
-# apache2-websockets instance. For example, in Debian
-# this file lives in /etc/apache2-websockets/sites-available/
-
-LogLevel info
-# - log locally
-CustomLog /var/log/apache2-websockets/access.log combined
-ErrorLog /var/log/apache2-websockets/error.log
-# Add the PID to the error log (Apache 2.4 only)
-# ErrorLogFormat "[%t] [%P] [%l] [pid %P] %F: %E: [client %a] %M"
-
-# ----------------------------------------------------------------------------------
-# Set up our SSL virtual host
-# ----------------------------------------------------------------------------------
-Listen 7682
-NameVirtualHost *:7682
-<VirtualHost *:7682>
- DocumentRoot /var/www
- ServerName localhost:7682
- ServerAlias 127.0.0.1:7682
- SSLEngine on
- SSLHonorCipherOrder On
- SSLCipherSuite ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM
-
- # re-use the certs from the main apache instance
- SSLCertificateFile /etc/apache2/ssl/server.crt
- SSLCertificateKeyFile /etc/apache2/ssl/server.key
-</VirtualHost>
-
-Listen 7680
-NameVirtualHost *:7680
-<VirtualHost *:7680>
- ServerName localhost:7680
- ServerAlias 127.0.0.1:7680
- DocumentRoot /var/www
-</VirtualHost>
-
-<Location /osrf-websocket-translator>
- SetHandler websocket-handler
- WebSocketHandler /usr/lib/apache2/modules/osrf_websocket_translator.so osrf_websocket_init
-</Location>
--- /dev/null
+# non-SSL websocket connections
+
+Listen 7680
+
+# SSL websocket connections
+
+<IfModule mod_ssl.c>
+ Listen 7682
+</IfModule>
+
+<IfModule mod_gnutls.c>
+ Listen 7682
+</IfModule>
--- /dev/null
+# :vim set syntax apache
+#
+# This is the top-level configuration file for the
+# apache2-websockets instance. For example, in Debian
+# this file lives in /etc/apache2-websockets/sites-available/
+
+LogLevel info
+# - log locally
+CustomLog /var/log/apache2-websockets/access.log combined
+ErrorLog /var/log/apache2-websockets/error.log
+# Add the PID to the error log (Apache 2.4 only)
+# ErrorLogFormat "[%t] [%P] [%l] [pid %P] %F: %E: [client %a] %M"
+
+# ----------------------------------------------------------------------------------
+# Set up our SSL virtual host
+# ----------------------------------------------------------------------------------
+Listen 7682
+NameVirtualHost *:7682
+<VirtualHost *:7682>
+ DocumentRoot /var/www
+ ServerName localhost:7682
+ ServerAlias 127.0.0.1:7682
+ SSLEngine on
+ SSLHonorCipherOrder On
+ SSLCipherSuite ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM
+
+ # re-use the certs from the main apache instance
+ SSLCertificateFile /etc/apache2/ssl/server.crt
+ SSLCertificateKeyFile /etc/apache2/ssl/server.key
+</VirtualHost>
+
+Listen 7680
+NameVirtualHost *:7680
+<VirtualHost *:7680>
+ ServerName localhost:7680
+ ServerAlias 127.0.0.1:7680
+ DocumentRoot /var/www
+</VirtualHost>
+
+<Location /osrf-websocket-translator>
+ SetHandler websocket-handler
+ WebSocketHandler /usr/lib/apache2/modules/osrf_websocket_translator.so osrf_websocket_init
+</Location>