cancel
Showing results for 
Search instead for 
Did you mean: 

F5 Redirect HTTP traffic to different ports based on context root

Manoj_Chavali
Nimbostratus
Nimbostratus

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 (https://abc.com) pointing to for example 21.12.3.8:8080.

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 https://abc.com/example1/*, the traffic should be routed to 21.12.3.8:8080. 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 21.12.3.8:8081, for /example3/* routed to 21.12.3.8:8082.

 

Hope we get pointed in the right direction.

 

Thanks

1 REPLY 1

Samir
Nacreous
Nacreous

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 : 21.12.3.8:8081],

Pool_8082[ Member : 21.12.3.8:8082]

 

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 } } }

Cheers..