Rewrite HTTP Redirect Port
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]]
Published Mar 18, 2015
Version 1.0hooleylist
Cirrostratus
Joined September 08, 2005
hooleylist
Cirrostratus
Joined September 08, 2005
- Steve_Janetzke_NimbostratusI 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_240062Nimbostratus
Did exactly what I was looking for. Same situation as Steve above. Thanks!