Forum Discussion

Skylark_233940's avatar
Skylark_233940
Icon for Nimbostratus rankNimbostratus
Aug 16, 2018

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
  }
}