STREAM::disable
# Check the requested path (set to lowercase)
# -glob: allow string pattern matching
switch -glob -- [string tolower [HTTP::uri]] {
“/ris1” {
log local0. “Matched pool 1 paths for [HTTP::uri]”
set uri [ string map -nocase { “/ris1” “/Novaris”} [HTTP::uri] ]
HTTP::uri $uri
HTTP::header remove “Accept-Encoding”
pool P1
}
“/ris2” {
log local0. “Matched pool 1 paths for [HTTP::uri]”
set uri [ string map -nocase { “/ris2” “/Novaris”} [HTTP::uri] ]
HTTP::uri $uri
HTTP::header remove “Accept-Encoding”
pool P2
}
“/ris3” {
log local0. “Matched pool 1 paths for [HTTP::uri]”
set uri [ string map -nocase { “/ris3” “/Novaris”} [HTTP::uri] ]
HTTP::uri $uri
HTTP::header remove “Accept-Encoding”
pool P3
}
default {
log local0. “Hit default for [HTTP::uri]”
HTTP::header remove “Accept-Encoding”
persist cookie insert “Redimed”
pool Pool_demobank
}
}
}
when HTTP_RESPONSE {
STREAM::disable
if {([HTTP::status] == 200) && ([HTTP::header value Content-Type] contains “text”) } {
STREAM::expression { @http@https@ @/Novaris@/ris1@ @/Novaris@/ris2@ @/Novaris@/ris3@ }
STREAM::enable
}
}
My problem is in the response.
When the server response because the payload don’t show the image so I fix with the stream:expression but with the other two not. Because the path have the same name there is another way to map this problem o I need to explain to the development team to modify the name of the path with each pool.
Hi @Juan_Carlos_Rom , are you using a OneConnect profile (to be assigned in the virtual server acceleration settings)?
As you are trying to “demultiplex” requests coming in through a clientside KeepAlive connection, it will be necessary to use OneConnect. Otherwise the incoming connection will be balanced to a pool according to your iRule logic and just stick there. With OneConnect enabled each incoming request will be handled individually.
I recommend to use a new OneConnect profile with a host mask of 32 bits (IPv4) or 128 bits (IPv6).
If I understand you correctly, you need to alter the stream expression in your HTTP_RESPONSE event, based either on the pool that was selected or the URI you received, during the HTTP_REQUEST event.
Note that you may need to capture that in a variable in the HTTP_REQUEST event, and check the variable in the HTTP_RESPONSE event, because you might only be able to use certain API functions inside certain events.
Something like:
when HTTP_REQUEST {<br> set orig_uri [HTTP::uri]<br> # the rest of your logic<br>}<br>when HTTP_RESPONSE {<br> STREAM::disable<br> if {([HTTP::status] == 200) && ([HTTP::header value Content-Type] contains "text") } {<br> switch -glob -- [string tolower $orig_uri] {<br> "/ris1*" {<br> STREAM::expression {@http:@https:@ @/[Nn]ovaris@/ris1@}<br> }<br> "/ris2*" {<br> STREAM::expression {@http:@https:@ @/[Nn]ovaris@/ris2@}<br> }<br> "/ris3*" {<br> STREAM::expression {@http:@https:@ @/[Nn]ovaris@/ris3@}<br> }<br> }<br> STREAM::enable<br> }<br>}
(There are other optimisations that might shorten this, but you should get the gist)
Note that I have also changed the expression for your http/https rewrite to http:/https: (note the colon), so that any https:// URI returned by the downstream server is not rewritten to httpss://.
You may also need to handle a case-sensitive response back from the downstream server (I presume you would need to rewrite /Novaris or /novaris for instance). To that end, you may need to make your stream search expression something like…
If the stream expression string starts or ends with space, it won’t work.
It looks neater with space, but it shouldn’t.
# This will work
STREAM::expression {@IE@Apache@ @Windows@Linux@}
# and this will work
STREAM::expression [list "@IE@Apache" "@Windows@Linux@"]
# but this will NOT work-- notice the space between the '{' and the '@'
STREAM::expression { @IE@Apache@ @Windows@Linux@ }