Forum Discussion
Tom_Lauwereins_
Nimbostratus
Mar 28, 2011TargetURL issue
I have an issue with "target URL"
When goiing to https://www.foo.com/abc
The webserver is redirecting for authenticating to https://www.foo.com/login.jsp?targetURL=http://www.foo.com/abc
Is it possible to rewrite the URL (via iRules) so the target URL is https://www.foo.com/abc instead of http://www.foo.com/abc
Now it happens on an apache with 'proxypassreverse'
Any suggestion?
Tom
5 Replies
- The_Bhattman
Nimbostratus
Hi Tom,
Yes you should be able to do this with the following untested iRulewhen HTTP_RESPONSE { set $find "http://www.foo.com/abc" set $replace "https://www.foo.com/abc" if {[HTTP::is_redirect] and [HTTP::header value Location] contains "?targetURL=http://www.foo.com/abc"} { HTTP::header replace Location [string map -nocase [-list $find $replace ] [HTTP::header value Location]] } }
I hope this helps
Bhattman - Tom_Lauwereins_
Nimbostratus
A got an error:
error: line 5: [undefined procedure: -list] [-list $find $replace ]
Any idea - Joel_Moses
Nimbostratus
when HTTP_RESPONSE { set find "http://www.foo.com/abc" set replace "https://www.foo.com/abc" if {[HTTP::is_redirect] and [HTTP::header value Location] contains "?targetURL=http://www.foo.com/abc"} { HTTP::header replace Location [string map -nocase [-list $find $replace ] [HTTP::header value Location]] } }
The variables for find and replace were not set right. The code above should be what you need. - JRahm
Admin
Just remove the dash in front of list:[string map -nocase [list $find $replace] [HTTP::header value Location]Also note that the "$" should not be present on the two set commands. In TCL shell:
% set find "http://www.foo.com/abc" http://www.foo.com/abc % set replace "https://www.foo.com/abc" https://www.foo.com/abc % set location "Location: http://www.foo.com/abc/home.html" Location: http://www.foo.com/abc/home.html % string map [list $find $replace] $location Location: https://www.foo.com/abc/home.htmlNote that setting the variables not only takes up unnecessary cpu/memory, but it also requires the list command in the string map, which takes extra cpu cyles. Would be better just to define them unless there are multiple potential matches. This would be shortened to:
when HTTP_RESPONSE { if {[HTTP::is_redirect] and [HTTP::header value Location] contains "?targetURL=http://www.foo.com/abc"} { HTTP::header replace Location [string map -nocase {"http://www.foo.com/abc" "https://www.foo.com/abc"} [HTTP::header value Location]] } }HTH...Jason
- JRahm
Admin
looks like Joel beat me to the punch, but you still need to remove the "-" in front of list as well as removing the "$" from the set commands.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
