Sep 06, 2016
HTTP reverse proxy irule help
I currently have an irule that redirects a specific URI to a third party site while rewriting the headers to keep the original URL in the address bar. Currently, the URIs are required to match between what the users types in and what is at the third party site. For example, www.abc.com/jobs/ ==> www.xyz.com/jobs/.
I now have a request to perform a similar redirect but the URIs don't match. www.abc.com/en-gb/jobs ==> www.xyz.com/en-gb.
I am looking for assistance in modifying my existing irule to make the new request work.
Here is an example of my current irule:
when CLIENT_ACCEPTED {
Store the default pool name
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { ([HTTP::uri] starts_with "/jobs")} {
HTTP::header replace Host "www.xyz.com"
set host [HTTP::host]
log local0. "client [IP::client_addr]:[TCP::client_port] server [IP::remote_addr]:[TCP::release] host $host"
log local0. "URI: [HTTP::uri]"
set dest [lindex [RESOLV::lookup @208.67.222.222 -a [HTTP::host]] 0]
if { $dest ne "https://www.xyz.com" } {
SSL::enable clientside
log local0. "Destination IP is $dest"
node $dest
}
} else {
log local0. "-->[HTTP::uri] $default_pool"
pool $default_pool
}
}
when HTTP_RESPONSE {
if {[HTTP::header exists Location]} {
set location [HTTP::header Location]
set locationrewrite [string map { www.xyz.com www.abc.com } $location]
HTTP::header replace Location $locationrewrite
}
STREAM::expression "@www.xyz.com@www.abc.com@"
STREAM::enable
}
Thanks