Skip to content

Proxy seedlink and datalink over websockets using apache2

Philip Crotwell edited this page Aug 2, 2023 · 4 revisions

To proxy seedlink and datalink via websockets from Apache2 to Ringserver:

See the Realtime Tutorial for how to configure the client javascript.

You can use any port > 1024, but I will assume ringserver configuration has ListenPort 6382. Also assuming that you want /ringserver urls to be proxied by Apache to ringserver.

Note that only ListenPort can do datalink and seedlink over web sockets. DatalinkPort and SeedlinkPort are for running the datalink or seedlink protocols over raw sockets and will not work with web sockets. You can test this by asking for the server id with a web browser,

http://<host>:6382/id

and you should see something like:

ringserver/2020.075
Organization: My Seismic Network

Other useful web pages supplied by ringserver are streams, streamids. See the ringserver documentation for more information.

If that works, enable all the mods you need:

sudo a2enmod proxy proxy_http2 proxy_http proxy_wstunnel

and then in your site's conf file:

    <IfModule mod_proxy.c>
        ProxyPassMatch "^/ringserver/(datalink)$" "ws://localhost:6382/$1"
        ProxyPassMatch "^/ringserver/(seedlink)$" "ws://localhost:6382/$1"
        ProxyPass "/ringserver" "http://localhost:6382"
        ProxyPassReverse "/ringserver" "http://localhost:6382"
    </IfModule>

and restart or reload apache, sudo apachectl graceful.

It is important that the items on the right hand side are ws:// or http:// as this is the connection to ringserver and it only allows non-secure ws and http protocols. This is true even if you are configuring Apache to listen to https. The connection from Apache out to the world can be https and wss, but the proxied connection from Apache to ringserver must be http and ws.

Then try a url like:

http://your.server.name/ringserver/id

to verify that the basic http proxy works. If this fails, then the websocket won't work either as a websocket starts as a http connection that then upgrades to a websocket.

If that is ok, then modify your realtime js file to connect to

ws://your.server.name/ringserver/datalink

or wss if you are doing secure connection. Modify the javascript like:

const datalink = new seisplotjs.datalink.DataLinkConnection(
  "ws://your.server.name/ringserver/datalink",
    packetHandler,
    errorFn);

Note that only the ListenPort is valid for http and/or web sockets. The raw seedlink and datalink ports can't do this.

Clone this wiki locally