I'm using docker in swarm mode for the services in my application and traefik to handle, well, the traffic. My goal is to make a separate service for each API section my application has (so for example requests on domain.com/api/foo_api
go to the foo_api
service and requests on domain.com/api/bar_api
go to the bar_api
service.
Now all this is pretty straightforward with traefik. However, I'm also using the API services with other internal services not related to the API. They use a websocket connection to the internal docker URL, so currently it's ws://api:api_port/ws
. However, if I split up the API part I'd need something like ws://foo_api:foo_api_port/ws
which obviously leaves the service only access to the foo_api
, not every other one.
So my question is: Can I route this websocket traffic with traefik similiar to how I do it externally, but internally in the docker net?