One of our web developers has asked me if we could strip off a port number in a redirect they are doing. I thought the following would do this, but it doesn’t appear to work.
when HTTP_REPSONSE {
if { [HTTP::is_redirect] } {
if { [HTTP::header Location] contains “www.acme.com:10040” } {
That should work fine to remove the port from redirects. However, the value for HTTP::header Location is cached in the same iRule event. and priority. You can get around this while testing by adding a second HTTP_REQUEST event:
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
if { [HTTP::header Location] contains "www.acme.com:10040" } {
log local0. "Original Location value: [HTTP::header Location]"
HTTP::header replace Location [string map -nocase {www.acme.com:10400 www.acme.com} [HTTP::header value Location]]
}
}
}
when HTTP_RESPONSE priority 501 {
if { [HTTP::is_redirect] } {
Debug logging only. Remove this event once done testing
log local0. "Updated Location value: [HTTP::header Location]"
}
}
hmm, tried what you suggested and the log entry in the other HTTP_RESPONSE section doesn’t display a value for the header, it is just blank.
I have used this code logic before and it worked, but the only difference was that the hostname was being changed with no explicit port numbers. I’ll do some more testing but is there any other way I could do this?
As I mentioned earlier I have pretty much the same block of code that does work, but there is one other major difference between these two situations. In the case where it works the redirect is generated on host-a to host-b whereas in the one that isn’t working it is redirecting to itself. Not sure if this should make a differene, but this along with the use of a port number are the only differences I can fathom at the moment.
On a positive side, it looks as if F5 engineering think they have finally tracked down the cause of our memory leak and can reproduce it in their labs. Yay!!!
** There is an issue where HTTP::header values can remove colons in the header values it returns. The actual header values are unchanged. This issue is tracked as CR98328. **
I’m wondering if this is the issue. I’ll do some more testing.
we are running 10.xxx and oddly enough it has started to work. Arrgh. All I did was to re-enter in the lines of code in the iRile and it started to work. Just wondering if somehow I managed to enter in a a non printable character somewhere. Odd, but it seems to be working consistantly now which is a releif. Now our developers have thrown up another request (sigh). I 'll start a new topic on this if I can’t nut it out by myself.
Once again thank for all of your help, past present and future!