Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Can I change a redirect to a new server address on the same loadbalancer?

Is there a way for a HTTP redirect to point to the same Loadbalancer but move the connection to another poolmember/node?

My attempt may explain better what I am trying to do:

when HTTP_REQUEST {
   set r_host [getfield [HTTP::host] ":" 1]
}

when HTTP_RESPONSE {
   if { [HTTP::is_redirect] }{
   set r_loc [HTTP::header Location]
    
   scan $r_loc "http://%d.%d.%d.%d:%d" ip1 ip2 ip3 ip4 port
   set ipaddress $ip1.$ip2.$ip3.$ip4
  
   #change to new server address (PROBLEM: traffic on way out, change has no effect)
   node $ipaddress $port
   
   # replace IP with DNS of Loadbalancer (and http>https)
   set r_loc [regsub -all http://$ipaddress:$port $r_loc https://$r_host]
   HTTP::header replace Location $r_loc
  }
}
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello,

Can you take a look this solution to check if it's what you are trying to look for?

VIDEO ARTICLELightboard Lessons: Vip Targeting Vip

0
Comments on this Answer
Comment made 17-Aug-2018 by Skylark 2

No, I ended up solving this with by adding X-Forwarder-Host to the redirect then catching the next reply.

when HTTP_REQUEST {
   if { [HTTP::header exists "X-Forwarded-Host"] } {
     set esp_proxy_redirect [HTTP::header "X-Forwarded-Host"]
     node "$esp_proxy_redirect"
   }
}
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

This will leak your internal IP address if you publish this to client

0