Forum Discussion
Remove a specific string in path on request and insert on response
Hi guys,
I have a challenge for you.
I have a policy which will redirect traffic to a different pool/node when the path starts with a specific string. This string must be removed before it is sent to the server.
How can I insert that string at the beginning of the path when the response comes back from the server, so that the paths returned to the client will be correct?
Example:
Request: https://host.xy/strawberry/xxx/yyy ----rewrite towards the server--- > https://host.xy/xxx/yyy
Response paths: /random_path ---rewrite towards the client---> /strawberry/random_path
Next request will then be: https://host.xy/strawberry/random_path
The "strawberry" string is unknown for the server, it is just to let BigIP redirect it to a different pool/node.
The string should of course be inserted only on URLs that are relative to the server or starts with "https://host.xy/".
Is it possible to do this with a stream profile? I can probably do it with an iRule (using HTTP::collect and HTTP::payload), but that will be more complex and harder for my colleagues to understand and maintain (they don't know iRules).
I hope you understand what I am trying to do.
Eljay I believe what you are looking for is a string map and the following should do exactly what you described in your example.
when HTTP_REQUEST priority 500 { if {[HTTP::uri] starts_with "/strawberry/"} { HTTP::uri [string map {"/strawberry/" "/"}[HTTP::uri]] pool pool_web } }
- Eljay
Cirrus
Thanks, but I can do this with a policy. It's easier for non-programmers to understand.
Eljay That is absolutely true and in that policy you would use the information from line 4 as a tcl expression in the traffic policy similar to what is shown in the following.
https://somoit.net/f5/f5-bigip-modify-uri-path-using-local-traffic-policy/
Recent Discussions
Related Content
* 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