Target Service Port Depending on Path Prefix

Hello everyone, I got the following scenario:

My service is exposing two ports, one for regular http requests and the other one for long polling stuff, also http. The frontend sends all requests dedicated to the long polling port via a path prefixed with /lp/. under the same domain. So basically:

  • -> websecure -> ??? -> myservice:8080
  • -> websecure -> ??? -> myservice:8081

My intuition was to solve this with router rules (Host + PathPrefix) but I don't know how to target the different ports of the service. Maybe by somehow attaching two load balancers to the same service as the port can be specified there?

Thanks in advance!

Well, I stumbled over the solution by chance while working on another project :smiley:

Here's what I've done (roughly):

  # ...
    # ...
    # Web interface
    - "``)"
    - ""
    - ""
    - ""
    # Long polling interface
    - "``) && PathPrefix(`/lp/`)"
    - ""
    - ""
    - ""

By default, docker creates one services named <parent-folder>-myservice and all routers refer to that, especially the routers defined.

The trick is to assign (and thereby declare) a service to each router explicitly.
Then, we can configure each service's load balancer separately.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.