Configure Apache 2 to enable the mod_proxy
and
proxy_wstunnels
modules. On Debian this can be done with:
$ sudo a2enmod proxy $ sudo a2enmod proxy_wstunnel $ sudo a2enmod rewrite
The application should be run over HTTPS to keep the login credentials secure, otherwise others can see and re-use those credentials.
Modify the server configuration to implement the following Apache
rewrite rules. Note that the default socket.io
path is prefixed
with wstrack\
so that multiple applications using websockets can
be run on the same Apache server using different prefixes. (TRIP uses
websockets to provide updates to the tracking map.) The TRIP web client
app will prefix the path when it is not calling a localhost URL. These
rules need to be in a <VirtualHost _default_:443/>
or
<Directory/>
section of the mod_ssl
configuration file.
RewriteEngine on RewriteCond %{REQUEST_URI} ^/wstrack/socket.io [NC] RewriteCond %{QUERY_STRING} transport=websocket [NC] RewriteRule /wstrack/(.*) ws://localhost:8080/$1 [P,L]
Add the following to trip.conf
outside the <directory\>
directive:
<IfModule mod_proxy.c> ProxyPass /wstrack/socket.io/ http://localhost:8080/socket.io/ ProxyPassReverse /wstrack/socket.io/ http://localhost:8080/socket.io/ ProxyPass /trip/rest http://localhost:8080 ProxyPassReverse /trip/rest http://localhost:8080 </IfModule>