cancel
Showing results for 
Search instead for 
Did you mean: 
hooleylist
Cirrostratus
Cirrostratus

Problem this snippet solves:

Intercepts server-set redirect responses & removes the server's port from the Location header.

Code :

when HTTP_RESPONSE {

   # Check if server response is a redirect
   if { [HTTP::header is_redirect]} {

      # Log original and updated values
      log local0. "Original Location header value: [HTTP::header value Location],\
         updated: [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]]"

      # Do the update, replacing :8080/ with / (where 8080 is the pool member's port)
      HTTP::header replace Location [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]]
   }
}

# Note: You could replace the current mapping, ":[TCP::remote_port]/ /", with the VIP port if the virtual server is on a non-standard port:

# Replace selected pool member's port with the VIP port
HTTP::header replace Location [string map ":[LB::server port]/ :[clientside {TCP::local_port}]/" [HTTP::header value Location]]
Comments
Steve_Janetzke_
Nimbostratus
Nimbostratus
I have a similar situation, but the redirects are http://website.test.com/Reports immediately sends redirect to http://website.test.com:4433/Reports/Pages/Folder.aspx If I create a custom http profile, chose the 'All' choice on the 'Rewrite redirects' option and associate it to the virtual server it fixes the port on the redirect, but it also changes the protocol to https. I thought I would check out fixing this with an iRule since the test developer wants to keep the dev instance http. I will try this code snippet - thanks Aaron!
Alex_240062
Nimbostratus
Nimbostratus

Did exactly what I was looking for. Same situation as Steve above. Thanks!

 

Version history
Last update:
‎18-Mar-2015 14:56
Updated by:
Contributors