HTTP_RESPONSE - STREAM::expression to replace one string with another in HTTP data payload
I am trying to replace any instance of a certain URI whenever it occurs in the HTTP response data. It occurs within JavaScript <script> tags of the HTML document. I have the default system stream profile on the virtual server, and I'm using an iRule. When I inspect the web page after in my browser, I still see the URI that I am trying to replace, even the first instance of it. Although, as I understand it from reading the content at the links below here, I am using STREAM::expression in my iRule, so I think it should replace all occurrences, not just the first. Seems to not be replacing any though. https://support.f5.com/csp/article/K39394712 https://clouddocs.f5.com/api/irules/STREAM__expression.html I have also checked these out: https://devcentral.f5.com/s/articles/ltm-stream-profile-multiple-replacements--regular-expressions https://clouddocs.f5.com/api/irules/STREAM__replace.html Here is what I have. # FQDN app.example.com resolves to ltm virtual server SNAT IP # if URI starts with /fooportal # then reverse proxy to https://example.com/fooportal # if the URI started with anything other than /fooportal # then 307 redirect to host example.com # but with the originally requested path # # when HTTP_REQUEST { # Disable the stream filter for client requests STREAM::disable # only requests to app.example.com will come to this virual server # app.example.com has a DNS Address record to this virtual server's SNAT IP Address # whereas the DNS Address record for example.com is the back-end real server address if { ([string tolower [HTTP::uri]] starts_with "/fooportal") } { HTTP::header replace Host "example.com" pool example.com_HTTPS_Pool } elseif { ([string tolower [HTTP::header host]] eq "app.example.com") } { HTTP::header replace Host "example.com" HTTP::respond 307 Location https://[HTTP::host][HTTP::uri] } } when HTTP_RESPONSE { # Disable the stream filter for server responses STREAM::disable # Enable the stream filter for text responses only if {([HTTP::status] == 200) && ([HTTP::header value Content-Type] starts_with "text")} { # Replace 'example.com' with 'app.example.com' STREAM::expression {@example.com/fooportal/@app.example.com/fooportal/@} # Enable the stream filter STREAM::enable } }1.1KViews0likes1CommentGetting HTML Page Title for iRule
Hi All, I am working on creating a new VIP with 2 servers(each server has its separate pool). One of the server have some issues and at times it directly through a Logout Page while accessing app page. As per app owner he wants to move traffic from one pool to other depending upon the HTML title page in HTTP Response Header. EX: If page Title is "XYZ" then move traffic to Pool-B and for all other Page title keep traffic to Pool-A. I suppose this could be achieved by an iRule but I am not able to fetch the HTML Title Page from HTTP Response Header. Can you pls help me here with the right configuration of iRule. Thanks in Advance.520Views0likes4CommentsAPM: change HTTP Response
I'm getting a "?" character on a response and I want to change it I'm using this: when HTTP_RESPONSE { set iRedirectResp [HTTP::header Location] log local0. "$iRedirectResp this made match!" if { [HTTP::header Location] contains "www.reaxis.com?" } { log local0. "the location made match on the IF" HTTP::respond 302 Location https://www.reaxis.com Server CompaniXServer } } Also I'm taking this logs: Dec 20 08:01:51 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.companyx.co/biblos/imagenes/menu2_r1_c1.gif Dec 20 08:01:51 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : this made match! Dec 20 08:01:54 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.companyx.co/biblos/bases_datos/titulo_r.php? Dec 20 08:01:54 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : https://www.reaxys.com? this made match! Dec 20 08:01:55 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.reaxys.com? Dec 20 08:01:55 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : this made match!499Views0likes8CommentsBIG-IP : irule : ensure only a single instance of a cookie is present
F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi I need to ensure that my response contains only a single instance of the the cookie mycookie and the value is set to 1 Will this work ? when HTTP_RESPONSE { if { [HTTP::cookie exists mycookie] } { HTTP::cookie remove mycookie } HTTP::cookie insert name mycookie value 1 } My tests seem to indicate that the remove command only removes a single cookie mycookie -- but it's difficult testing. Also : by default are all request cookies automatically included in the response ( assuming no irule manipulation of cookies )257Views0likes2Comments