on 18-Mar-2015 14:56
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]]