Forum Discussion
http redirect irule
I am working on a irule which basically strips "/abchef" on the URI before loadbalancing to a pool here is my rule, the issue is if I remove "log local0" or "log" from this rule it did not work, is there a better way to do it
when HTTP_REQUEST {
if { [HTTP::host] contains "testlab.john.com" and [HTTP::uri] starts_with "/abcdef/api/" }
{
log local0[substr [HTTP::uri] 7]
pool testlab } }
- cjunior
Nacreous
Hi, I'm not sure what you need. You just need to log:
when HTTP_REQUEST { if { [HTTP::host] contains "testlab.john.com" and [HTTP::uri] starts_with "/abcdef/api/" } { log local0. "[substr [HTTP::uri] 7]" pool testlab } }
or you need to strip and rewrite uri before send to a server:
when HTTP_REQUEST { if { [HTTP::host] contains "testlab.john.com" and [HTTP::uri] starts_with "/abcdef/api/" } { log local0. "[substr [HTTP::uri] 7]" HTTP::uri [substr [HTTP::uri] 7] pool testlab } }
Regards.
- cjunior
Nacreous
John, I still can't see when are removing the complete log statement line, the iRule stops to work. But, if you are just trying to run "[substr [HTTP::uri] 7]" on this line, it's really wrong thing. You need to store back on HTTP::uri.
HTTP::uri [substr [HTTP::uri] 7] pool testlab
This way, on client side the URI should be:
, and on server side, the URI should be:/abcdef/api/
/api/
Anyway, If you are facing issue when you do strip to uri value, and the traffic have an unexpected redirection because of the irule 1 execution, you can try to set priority to this irule. This way, it will execute before the iRule that you are rewriting the uri. e.g.
irule 1 when HTTP_REQUEST priority 300 { if { [HTTP::host] contains "testlab.john.com" and [HTTP::uri] starts_with "/api/" } { HTTP::redirect "https://f5.com[HTTP::uri]" } } irule 2 when HTTP_REQUEST { if { [HTTP::host] contains "testlab.john.com" and [HTTP::uri] starts_with "/abcdef/api/" } { HTTP::uri [substr [HTTP::uri] 7] pool testlab } }
I think I have no more ideas to this.
Respectfully.
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