Forum Discussion
lisiecki_54902
Nimbostratus
Jun 10, 2009https redirect to pool based on uri
I have looked though many examples. I recieve an https request and I need to forward to a pool based on uri:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/thing1" } {
pool thing1
}
if { [HTTP::uri] starts_with "/thing2" } {
pool thing2
}
}
The syntax is accepted, the pools are created and I can get a valid web page if I go directly to the servers.
Any pointers would be appreciated.
Thank-you
- The_Bhattman
Nimbostratus
Are you passing the SSL traffic or does it terminate on the F5?when HTTP_REQUEST { switch -glob [HTTP::uri] "/thing1*" { pool thing1} "/thing2*" { pool thing2} } }
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/thing1" } { pool thing1 elseif { [HTTP::uri] starts_with "/thing2" } { pool thing2 } }
- lisiecki_54902
Nimbostratus
First, Thank-you for the reply. - Colin_Walker_12Historic F5 AccountYep, you sure can. Just make sure you're adding the port after the host, not after the URI.
- lisiecki_54902
Nimbostratus
I need to take an https request, terminate the SSL and forward to a pool. - JRahm
Admin
So just to clarify, you have a virtual that is x.x.x.x:443, you are terminating ssl on this virtual, and then you want to forward the unencrypted requests, with uri intact, to y.y.y.z:1081 pool members? If that is the case, just define your pool members with the desired port and let the LTM translate the port for you (it will by the default parameters in the virtual/pool configurations). So you would define your pool members as: - lisiecki_54902
Nimbostratus
Thanks, I have it configured as stated and my tcpdump shows the translation. I just opened a case. I'm running 9.3.0. - lisiecki_54902
Nimbostratus
solution, - hoolio
Cirrostratus
You can save resources by not checking further options once one match is done. You can do this by using if/elseif/else logic or a switch statement:when HTTP_REQUEST { Check requested path with wildcard support switch -glob [HTTP::path] { "/thing1*" { Rewrite host header value and select pool HTTP::header replace Host a.b.c:1082 pool thing1pool } "/thing2*" { Rewrite host header value and select pool HTTP::header replace Host a.b.c:1080 pool thing2pool } "/" { Redirect client HTTP::redirect "https://a.b.c/thing1" } default { Rewrite host header value and select pool HTTP::header replace Host a.b.c:1080 pool thing2pool } } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects