Forum Discussion
Mulitple URL Replace and stream profile
I have a case where the internal naming of multiple servers have to be replaced by a single FQDN. I am succesful when dealing with one instance but not with many. Here is my current iRule, note: it seems to never hit on the second object.
when HTTP_RESPONSE {
if { [HTTP::is_redirect]} {
HTTP::header replace Location "[string map -nocase [list inside1.net fqdn.com] [HTTP::header value Location]]"
} else {
HTTP::header replace Location "[string map -nocase [list inside2.net fqdn.com] [HTTP::header value Location]]"}
}
Also; I have a stream profile applied to the VIP:
Source is blank.
Target: @inside1.net@fqdn.com@ @inside2.net@fqdn.com@
Any help would be much appreciated!
18 Replies
- What_Lies_Bene1
Cirrostratus
Can you try this please? I've added some spaces (which probably won't help) and some logging that might;when HTTP_RESPONSE { if { [HTTP::is_redirect] } { HTTP::header replace Location "[string map -nocase [list inside1.net fqdn.com] [HTTP::header value Location]]" } else { log local0. "Changing inside2.net location header" HTTP::header replace Location "[string map -nocase [list inside2.net fqdn.com] [HTTP::header value Location]]" } } - zipperbox_11405
Nimbostratus
Thanks. Tried it and again it only works for the first item, in this case it replaced inside1.net to fqdn.com but it always seems to fail on the following item(s) no matter the order.
Jan 14 15:35:43 tmm tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:43 172.16.10.88 local/tmm info tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:43 172.16.10.88 local/tmm info tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:44 tmm tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:44 172.16.10.88 local/tmm info tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:44 172.16.10.88 local/tmm info tmm[5009]: Rule Test-Else : Changing inside2.net location header
Jan 14 15:35:45 tmm tmm[5009]: Rule Test-Else : Changing inside2.net location header - What_Lies_Bene1
Cirrostratus
OK, so how about we make it real simple;when HTTP_RESPONSE { if { [HTTP::is_redirect] } { HTTP::header replace Location "fqdn.com" } else { log local0. "Changing inside2.net location header" HTTP::header replace Location "fqdn.com" } } - What_Lies_Bene1
Cirrostratus
Btw, is the Stream profile working OK? - nitass
Employee
e.g.[root@ve10:Active] config b virtual bar80 list virtual bar80 { snat automap pool foo destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_RESPONSE { if { [HTTP::is_redirect]} { HTTP::header replace Location "[string map -nocase [list inside1.net fqdn.com inside2.net fqdn.com] [HTTP::header value Location]]" } } } original response [root@ve10:Active] config curl -I http://200.200.200.101/something1 HTTP/1.1 302 Found Date: Tue, 15 Jan 2013 04:17:33 GMT Server: Apache/2.2.3 (CentOS) Location: http://inside1.net/somethingone Content-Type: text/html; charset=iso-8859-1 [root@ve10:Active] config curl -I http://200.200.200.101/something2 HTTP/1.1 302 Found Date: Tue, 15 Jan 2013 04:17:34 GMT Server: Apache/2.2.3 (CentOS) Location: http://inside2.net/somethingtwo Content-Type: text/html; charset=iso-8859-1 response through bigip [root@ve10:Active] config curl -I http://172.28.19.252/something1 HTTP/1.1 302 Found Date: Tue, 15 Jan 2013 04:19:27 GMT Server: Apache/2.2.3 (CentOS) Location: http://fqdn.com/somethingone Content-Type: text/html; charset=iso-8859-1 [root@ve10:Active] config curl -I http://172.28.19.252/something2 HTTP/1.1 302 Found Date: Tue, 15 Jan 2013 04:19:28 GMT Server: Apache/2.2.3 (CentOS) Location: http://fqdn.com/somethingtwo Content-Type: text/html; charset=iso-8859-1 - zipperbox_11405
Nimbostratus
Thanks - but unfortunately neither of these suggestions worked. The following was really close but didn't quite like the directories.
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
HTTP::header replace Location "fqdn.com" }
else {
log local0. "Changing inside2.net location header"
HTTP::header replace Location "fqdn.com" }
} - nitass
Employee
but unfortunately neither of these suggestions worked. hmm... would you mind showing us what is not working? - zipperbox_11405
Nimbostratus
When using the following iRule:
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
HTTP::header replace Location "fqdn.com" }
else {
log local0. "Changing inside2.net location header"
HTTP::header replace Location "fqdn.com" }
}
Trying to render either inside1.net or inside2.net the following error(s) occur...
java.io.FileNotFoundException: /content/players/fqdn.com - hoolio
Cirrostratus
You're replacing the Location header with just fqdn.com. The browser assumes that means it should make a new GET request to it's current host/URL + fqdn.com. If they'd requested http://www.example.com/path, they'd make a new request to http://www.example.com/path/fqdn.com which isn't what you want.
Can you try Nitass's suggestion and reply back with what you find?
HTTP::header replace Location "[string map -nocase [list inside1.net fqdn.com inside2.net fqdn.com] [HTTP::header value Location]]"
If this doesn't work, can you log the new location header value and describe what request the client makes and the server's response?
log local0. "New Location: [HTTP::header replace Location]"
Aaron - zipperbox_11405
Nimbostratus
So this irule is very very close...
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
HTTP::header replace Location "fqdn.com" }
else {
log local0. "Changing inside2.net location header"
HTTP::header replace Location "fqdn.com" }
}
But the header replace is almost doing to much... see the URL below following the replace. The trailing portion after "/players/" is being rewritten as well...
http://fqdn.com/Saba/Web_wdk/AFIILE/content/players/fqdn.com
This is what it should be...
http://fqdn.com/Saba/Web_wdk/AFIILE/content/players/SequencedPlayerRedirect.rdf?caller=&contextId=ctctx000000000001772&returnToCatalog=&callerId=&contentServerId=media000000000000002&contentFormat=SCORM&contentInventoryId=cninv000000000001048&startUserSession=&subscriptionId=ctnsr000000000001191&cfversion=1.3.1&isContentComplianceTestMode=
In wireshark this is what we see happening...
[truncated] GET http://fqdn.com/Saba/Web_wdk/AFIILE/content/players/redirect_content_url_new.rdf?contextId=ctctx000000000001772&subscriptionId=ctnsr000000000001191&contentInventoryId=cninv000000000001048&contentServerId=m
[truncated] GET http://fqdn.com/Saba/Web_wdk/AFIILE/content/players/SequencedPlayerRefresh.rdf?contextId=ctctx000000000001772&subscriptionId=ctnsr000000000001191&contentInventoryId=cninv000000000001048&contentServerId=med
GET http://fqdn.com/Saba/Web_wdk/AFIILE/content/players/fqdn.com HTTP/1.1\r\n - PROBLEM
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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