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"
}
Kevin,
Ignore the HTTP Response part, I have just kept that for logging purpose. The original request was to rewrite the uri before sending it to the server
client ---- BIGIP : http://name.domain.com/abc/ten/spa/
BIGIP --- server : http://spa.ten.name.domain.com/abc/
The below irule will do the works as per the requirement?
IRULE:
when HTTP_REQUEST {
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]
}
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
