Forum Discussion
irule for URL remap
Thank you kevin for the response, is the below irule will do the URI rewrite , if the browser/client hits the F5 vip with http://name.domain.com/abc/ten/spa and the backend server should receive with uri rewrite as http://spa.ten.name.domain.com/abc
On the LTM by doing a curl command it shows that uri rewrite happens , but when we checked HTTP_RESPONSE log and the backend server log, it receives the request as it is ( http://name.domain.com/abc/ten/spa )
did I miss something in the irule ? please advise
when HTTP_REQUEST {
set vip [IP::local_addr]:[TCP::local_port]
set url [HTTP::header Host][HTTP::uri]
set URI [string tolower [HTTP::uri]]
if {[HTTP::uri] contains "/abc/"} {
scan $URI {/%[^/]/%[^/]/%[^/]/} a b c
log local0. $b
log local0. $c
**HTTP::uri "http://$c.$b.name.domain.com/abc/"**
log local0. [HTTP::uri] }
else{
scan $URI {/%[^/]/%[^/]/} a b
log local0. $a
log local0. $b
HTTP::uri "http://$b.$a.name.domain.com/"
log local0. [HTTP::uri]
}
}
when HTTP_RESPONSE {
set client [IP::client_addr]:[TCP::client_port]
set node [IP::server_addr]:[TCP::server_port]
set nodeResp [HTTP::status]
log local0.info "Client: $client -> VIP:$vip$url -> Node: $node with response $nodeResp"
}
HTTP_RESPONSE deals with the information sent to you from the server. This has nothing to do with the iRule provided which deals entirely with traffic being passed to the server. The two are not the same. While one is caused by the other, traffic going to the server is generated by the client. Traffic coming from the server is generated by the server in response to the request from the client. Since this is not being modified you get it as is.
If this is not what you want the you need to modify the original iRule to modify the response from the server. Because this is now modifying content and no longer just a header this becomes more complicated. I think you should resubmit your original request with a lot more information. Then you are far more likely to get a response which gives you the desired outcome.
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
