Forum Discussion

Manoj_Chavali's avatar
Icon for Nimbostratus rankNimbostratus
Jul 01, 2020

F5 Redirect HTTP traffic to different ports based on context root

Hello folks,


We have an application built on microservices i.e. each component within the application is hosted on the same machine but different tomcat instances i.e. different ports (8080, 8081, 8082).


Scenario: We have a virtual server ( pointing to for example

Based on the context root, I would like the traffic to be routed to different ports where they are hosted.


E.g. /example1 is hosted on port 8080, /example2 is on 8081, /example3 is on 8082.

If the url is*, the traffic should be routed to If the user clicks another tab on the application UI then the context root changes from /example1 to /example2 etc and F5 should redirect it to a different tomcat instance on the same machine i.e. If context root changes to /example2/* then traffic to be routed to, for /example3/* routed to


Hope we get pointed in the right direction.



1 Reply

  • This can be achieve via iRule or F5 Policy.

    Create the Pool based on the port wise and route the traffic on URI pattern. .

    Example: Pool_8081 [ Member :],

    Pool_8082[ Member :]

    And route the traffic based on pattern. This is an example you can modify based on requirements

    when HTTP_REQUEST {
    set uri [string tolower [HTTP::uri]]
    switch -glob $uri {
          "/example1/*" {
           pool Pool_8081
          "/example2/*" {
           pool Pool_8082