F5 BIG-IP icon   F5 BIGIP – Modify URI path using local traffic policy



Im using my F5 BIGIP (v13) as reverse proxy to publish some websites by using local traffic policies. But i need to perform a URL rewriting. To be specific, i need to strip a string from the URI path.

It could be done using an IRule:

when HTTP_REQUEST{
if { [string tolower [HTTP::uri] ] starts_with "/path1" } {
  HTTP::uri [string map {"/path1/" "/"} [HTTP::uri]]
  node 10.10.10.20 8000
}
}

Given that im using policies to publish these websites, I tried to strip the string from the path using a policy action that allows to modify the path. Finally achieved this way:
F5 BIGIP - Modify URI path using local traffic policy 1

One of the allowed actions is Replace – HTTP Uri – PATH … with value…
F5 BIGIP - Modify URI path using local traffic policy 2

“value” can be a tcl expression like the one used in the IRule, but using this format:

tcl:[string map {"/path1/" "/"} [HTTP::uri]]

This way there is no need of an IRule (that would be processed after the policy).

4 thoughts on “F5 BIGIP – Modify URI path using local traffic policy

  1. Hello Sir,
    I’ve recently implemented one url on the local traffic policy but it does n’t work for us. I think may be the redirection failed.
    . can you check and guide me please

    Context : https://example.com/policy/ => http://toto:1337/
    a) config on the local traffic policy :
    Match all of the following conditions :
    Http header –> host –>starts with –> any of –> example.com –> request
    *options
    Http uri –> path –> starts with –> anyof –> /policy/ –> request

    Do the following conditions when the trafic is matched :
    Forward traffic –> pool –> toto –> request

Leave a Reply

Your email address will not be published. Required fields are marked *