Forum Discussion
splavery_111804
Nimbostratus
May 22, 2008Remove port redirect from URL
Hi, newbie here with what should be an easy iRule.
We use port redirects on our http and https sites, but in some cases, the redirected port gets inserted into the URL and passed back to the client and obviously breaks the session.
Example: https://secure.mysite.com:8467/comparison.aspx
I've tried to write a couple of irules to remove the 8467, without success.
Any help is greatly appreciated.
- hoolio
Cirrostratus
Hi there,when HTTP_RESPONSE { Check if a response is a redirect if {[HTTP::is_redirect]}{ log local0. "Original Location: [HTTP::header value Location]" Assume the server will use it's own TCP port in redirects and remove it. HTTP::header replace Location [string map [list ":[LB::server port]" ""] [HTTP::header value Location]] log local0. "Updated location (string map): [string map [list :[LB::server port] ""] [HTTP::header value Location]]" Use regsub to remove the colon and any characters up to the next forward slash. HTTP::header replace Location [regsub {:[0-9]+?(?=/)} [HTTP::header value Location] ""] log local0. "Updated Location (regsub): [regsub {:[0-9]+?(?=/)} [HTTP::header value Location] ""]" } }
- hoolio
Cirrostratus
It looks like the forum is breaking the display of some meta-characters after the upgrade. The regex should be { : [ 0 - 9 ] + ? ( ? = / ) } without any spaces. - splavery_111804
Nimbostratus
Thanks for the reply, but I can't quite get this to work without error. I'm probably not replacing some of your commands with the right variables for this site. - splavery_111804
Nimbostratus
(post deleted) - hoolio
Cirrostratus
You should be able to check what the original location header value was in the /var/log/ltm log file. The above rule wouldn't have modified the protocol. If you want to change it from http:// to https://, you can modify the rule:when HTTP_RESPONSE { Check if a response is a redirect if {[HTTP::is_redirect]}{ log local0. "Original Location: [HTTP::header value Location]" Assume the server will use it's own TCP port in redirects and remove it. Also replace http:// with https://. HTTP::header replace Location [string map -nocase [list http:// https:// ":[LB::server port]" ""] [HTTP::header value Location]] log local0. "Updated location (string map): [string map -nocase [list http:// https:// ":[LB::server port]" ""] [HTTP::header value Location]]" } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects