question

Load balancer - traffic distribution between containers according to URL.

Hi!

How can I route traffic based on URL?

For example:

https://<my_domain>/ - goes to one container

https://<my_domain>/<path1> - goes to a second container

https://<my_domain>/<path2> - goes to another container

Thanks!

avatar
11
  • Hey Ruslan,

    You can do this by creating load balancer routes and utilizing path matches plus redirects.

    Environment -> Services -> Manage (next to Load Balancer) -> Controllers -> Port 443 -> Config -> Routers.

    When you create your routes, remember that order matters -- first match wins. The most specific path will need to be at the start.

    I believe Chris or Alex is working on a guide for this in our documentation.

    avatar
    platform
  • Hi Jake!

    Am I correct in understanding that when assigning a container in the LB, the LINKED record in DNS does not matter? Is it possible to use any logical operators, such as &&, ||, or !, in URL definitions? Does the URL need to be exact, or will the rule apply to all nested URLs as well?

    avatar
  • Hi,
    I navigated to Environment -> Services -> Manage (next to Load Balancer) -> Controllers -> Port 443 -> Config -> Routers, but I don’t see any options for configuring URL-based routing there. Deployment has been completed with two servers and three containers, each running two instances for high availability. The container pointed to by the LINKED record is working.

    avatar
  • No LINKED Records. Containers are only resolvable via HTTP/S over the public internet when they have a LINKED record.

    avatar
  • Hi Ruslan,

    Correct, Linked records help teach the load balancer how traffic is routed.

    On the routers, do you see a field named "Path Match" ?

    avatar
    platform
  • Yes, I have three containers, each with two instances: home, awards, and youtube.

    I ended up creating three LINKED records, one for each, as otherwise, it resulted in an error.

    Each container has its own path:

    home - / awards - /awards youtube - /youtube I configured the Load Balancer settings under the Config section for each container according to its path and for port 443.

    However, it’s unclear what is meant by "Match Internal Port(s)" since I already defined port mapping during the container deployment.

    Also, access to the containers (except for home) via their network addresses is not working.

    avatar
  • Hi Jake!

    I’ve reviewed the documentation, but it’s still unclear how the LINKED record should look if I need to route traffic between three containers.

    Should I specify one container out of the three in the LINKED record? Or should I create three separate LINKED records, one for each container?

    avatar
  • Hi Ruslan,

    Are the three containers at different domains, or are they using the same domain? Are they using different ports?

    avatar
    platform
  • Hi Jake!

    All containers are on the same domain but on different paths. All three use ports 443 and 80.

    avatar
  • Normally this would be configured with the LB Routers using a path match. There's currently a race condition that exists when path match is used (it's a relatively new feature).

    As a temporary measure, I'd suggest using nginx service as the destination for the linked record for all 3 domains, then have nginx to the path matching and forwarding for the requests.

    avatar
    platform
v2025.01.14.01 © 2024 Petrichor Holdings, Inc.