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

Filter by:
  • Solution
  • Technology
code share

HTTP to HTTPS Location rewrite with custom port

Problem this snippet solves:

The SSL port is assigned in the following line:

lreplace $loc_list 2 2 [lindex [split [lindex $loc_list 2] ":"] 0]:80

change the ':80' to any required port to remove to remove any port assigned within the Location Header.

Tested on Version:
Comments on this Snippet
Comment made 05-Jan-2017 by Pavel Stoyanov 0

Getting the following error on BIG-IP v11.

01070151:3: Rule [/Common/HTTP_to_HTTPS_Location_rewrite_with_custom_port] error: /Common/HTTP_to_HTTPS_Location_rewrite_with_custom_port:14: error: [wrong # args][lreplace [$loc_list 0 0 "https:"]] /Common/HTTP_to_HTTPS_Location_rewrite_with_custom_port:19: error: [wrong # args][lreplace [$loc_list 2 2 [lindex [split [lindex $loc_list 2] ":"] 0]:80]]

Comment made 26-Jan-2017 by 7Samurai 0

Same comment as above. What gives? Does anyone read these comments? This irule, as written, generates the errors Pavel Stoyanov pasted above. How do we fix this?

Comment made 15-Dec-2017 by Stanislas Piron 10454

lreplace command doesn't replace any value in list but returns a new list with replaced value.

you can use this command :

set loc_list [lreplace $loc_list 0 2 https {} [lindex [split [lindex $loc_list 2] ":"] 0]:80]


set loc_list [lreplace $loc_list 0 2 https {} [getfield [lindex $loc_list 2] ":" 0]:80]