Current reverse proxy irule having issues with the third party hosted site
I currently have a client requirement to reverse proxy specific URI traffic to a third party hosted site while the rest of the traffic is sent to our local datacenter servers. Also, the URL in the address bar must show our address instead of the third party URL. The below irule is working for the most part, but after further testing, we ran into this issue.
If i go to www.abc.com/it-jobs/login, the irule will redirect the traffic to the third party site. If i replace the /it-jobs/login with /testimonials, it should take me back to the local datacenter servers, but i get a 404 error and the third party site is seeing the errors on their side. If i open a new browser and go directly to https://www.abc.com/testimonials, it works every time. If I go to https://www.abc.com/it-jobs/login, i get redirected to the correct page on the third party site. If i replace the /it-jobs/login with /testimonials, i get the 404 error. The third party site is pointing to the reverse proxy irule but i can't see anything in the irule that would create that symptom.
Any help would be appreciated.
Thanks
when CLIENT_ACCEPTED {
Store the default pool name
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if { ([HTTP::uri] starts_with "/it-jobs/")} {
HTTP::header replace Host "www.xyz.com"
log local0. "client [IP::client_addr]:[TCP::client_port] server [IP::remote_addr]:[TCP::release] host $host"
set dest [lindex [RESOLV::lookup @8.8.8.8 -a [HTTP::host]] 0]
if { $dest ne "https://www.xyz.com" } {
SSL::enable clientside
log local0. "Destination IP is $dest"
node $dest
}
} else {
SSL::disable serverside
}
}
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
}