A script to proxy the AIS stream that the comar unit provide as websocket.
Script connects to the Comar AIS web UI to fetch a SID, then sets up a websocket connection. It simulates the three-way-handshake that the browser does to get the stream.
This is then published at :8080
The script runs using node.js: node proxy.js
Then you can publish it using a reversed proxy with a tool such as nginx, apache etc.
The proxy now reads runtime configuration from environment variables instead of hard-coded globals.
AIS_HOST— Comar AIS host IP or hostname (required)AIS_PROTOCOL— HTTP scheme for the AIS UI (httpby default)WS_PROTOCOL— WebSocket scheme for the AIS stream (wsby default)LOCAL_PORT— local listen port (8080by default)RECONNECT_DELAY_MS— reconnect delay in milliseconds (5000by default)VERBOSE— enable debug logging (trueor1)
Example:
AIS_HOST=192.168.1.168 \
LOCAL_PORT=8080 \
VERBOSE=true \
node proxy.jsA Dockerfile is included to build a container image for the proxy.
docker build -t ghcr.io/<OWNER>/comar-ais-proxy:latest .docker run --rm \
-e AIS_HOST=192.168.1.168 \
-e LOCAL_PORT=8080 \
-e VERBOSE=true \
ghcr.io/<OWNER>/comar-ais-proxy:latestA workflow is included at .github/workflows/publish-ghcr.yml.
It builds and pushes the image to ghcr.io/${{ github.repository_owner }}/comar-ais-proxy on pushes to main.
Sometimes you want the data, but without exposing the comar unit... this is one way.
Node.js and some modules: axios and ws
optional: roxy software