string
9 TopicsPrint string found in Data Group to Log
I have an iRule that is looking in the HTTP POST request method data payload for a string that is defined in a data-group. I would like to print to the log whichever string from the referenced data-group is found. # See https://devcentral.f5.com/s/question/0D51T00006i7hpJSAQ/irule-to-block-requests-with-specific-word # #ltm data-group internal restricted_dg { #records { #restricted {} #} #type string #} when HTTP_REQUEST_DATA { set payload [HTTP::payload] if {[class match [string tolower $payload] contains "restricted_dg"]} { # set variable named restricted_text to the string found in $payload # that matches something in data-group restricted_dg log local0. "Rejecting restricted content $restricted_text" reject } }500Views1like2CommentsProblem with doubly-quoted string
This is related to this previous question I asked: https://devcentral.f5.com/questions/adding-cors-response-headers I am now having a separate problem related to a new version of sample code in that thread, which was trying to return CORS headers automatically. Here's the problem fragment: if { ( [HTTP::method] equals "OPTIONS" ) and ( [HTTP::host] contains "example.com"] ) and ( [HTTP::header] exists "Access-Control-Request-Method") } { HTTP::respond 200 "Access-Control-Allow-Origin" "[HTTP::header Origin]" "Access-Control-Allow-Methods" "POST, GET, OPTIONS" "Access-Control-Allow-Headers" "[HTTP::header Access-Control-Request-Headers]" "Access-Control-Max-Age" "86400" } elseif { ( [HTTP::host] contains "example.com"] ) and ( [HTTP::header] exists "Origin") } { CORS GET/POST requests - set cors_origin variable set cors_origin [HTTP::header Origin] } As you can see, each of the CORS response header names in the second line is enclosed in double-quotes, so the iRule treats them as strings. However, when I try to deploy the iRule that contains this fragment, it fails, and I'm not sure why. Could the problem be this bit: "Access-Control-Allow-Headers" "[HTTP::header Access-Control-Request-Headers]" Could the iRule think that Access-Control-Request-Headers is not a string? If so, what's the solution? Can I have a string within a string - I'm assumign this isn't valid: "Access-Control-Allow-Headers" "[HTTP::header "Access-Control-Request-Headers"]"453Views0likes2CommentsLTM Health Monitors
Hi team. I want to ask a question about health monitors. I have a Web site (www.example.com) behind the Load Balancer. I created a health monitor and I wrote send string : ''GET / HTTP/1.1\r\nHost:www.example.com\r\nConnection: Close\r\n\r\n'' I wrote recieve string : HTTP 1.1 200 OK And application is avaliable. VS is online (green circle) Then I changed receive string to : ''GET / HTTP/1.1\r\nHost:www.f5lab.com\r\nConnection: Close\r\n\r\n. So I replaced host with an unrelated name. And application is available again :) VS is online (green circle) How should we interpret this? Do you know good article or videos about send and recieve string? Thank you..406Views0likes2CommentsIRULE - Search in http query and set two variables
Good afternoon, sorry for my English. I need to store two variables from a uniq query. For example: www.example.com/test.jpg?aserver=2&bserver=3 I need a irule looking aserver value and save in variable val_Aserver. And too looking bserver value and save in another value, val_Bserver . I've been looking and can not find how to do it. Right now I have the following code: set val_Aserver [string range [HTTP::uri] [expr {[string first "aserver=" [HTTP::uri]] + 8}] end] set val_Bserver [string range [HTTP::uri] [expr {[string first "bserver=" [HTTP::uri]] + 8}] end] This only just save me the first value that I pass from the query, If I put www.example.com/test.jpg?aserver=2&bserver=3, correctly save val_Aserver is 2, but the val_Bserver is empty. If I put www.example.com/test.jpg?bserver=5&aserver=4 , correctly save val_Bserver is 5, but the val_Aserver is empty. I'm going crazy, someone can help me please? Thank you very much.356Views0likes1CommentString Trim returning odd results
I am using a variable assign action in an APM policy to remove leading/trailing spaces from the username entered into the logon page. session.logon.last.username = expr { [string trim [mcget {session.logon.last.username}] ] } For the most part this works fine, but there are some usernames that being unexpectedly altered by this function. Note that all usernames are comprised of numbers, not letters. The following are some examples of how the username looks before and after this variable assign: 02045604 --> 543620 03276501 --> 884033 Any idea why this would be happening? Is the username variable possibly being treated as an integer instead of a string?349Views0likes1CommentiRule to read dynamic file in /tmp/ location
Hi All, I've been trying to figure out if there is a way for an iRule to read from a file located in the /tmp/ directory on itself (LTM). The reason for this is I have a script running as a cronjob on the LTM to generate a unique string that I want to be able to manipulate and use in this iRule. So in summary, can an irule read from a location on the itself(LTM) and store it as a string? Thanks!320Views0likes3CommentsGeoblock exception based on user agent
Hi, We have Geo-blocking enabled for one of our apps and want to allow access from a third party tool that has a very specific user agent. Is it possible to allow requests from a geo blocked location when the user agent matches a particular string? Thank you.307Views0likes1CommentExtract headers from TCP payload
Hi, I have VS without http profile, but it can process http traffic. When using TCP::collect I am getting something like that in TCP::payload "GET /?ip=10.20.10.2 HTTP/1.1 Accept: image/jpeg, image/gif, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, / Accept-Language: en-US User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; vWorkspace) Accept-Encoding: gzip, deflate Host: wpad.test.com Connection: Keep-Alive " - don't know why no \r\n here? findstr $str "Host: " 6 - do not terminate on end of line, so it returns "wpad.test.com Connection: Keep-Alive " - obviously because how TCP::payload is presented as a string. What could be used to reliably extract only host from Host header? To retrieve method and URI scan [TCP::payload] {%[^ /]%s} method uri seems to be working ok Now the question is if findstr and scan methods are correct here, or it could be implemented more elegant/efficient? Piotr255Views0likes0CommentsExtract headers from TCP payload
Hi, I have VS without http profile, but it can process http traffic. When using TCP::collect I am getting something like that in TCP::payload "GET /?ip=10.20.10.2 HTTP/1.1 Accept: image/jpeg, image/gif, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, / Accept-Language: en-US User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; vWorkspace) Accept-Encoding: gzip, deflate Host: wpad.test.com Connection: Keep-Alive " - don't know why no \r\n here? findstr $str "Host: " 6 - do not terminate on end of line, so it returns "wpad.test.com Connection: Keep-Alive " - obviously because how TCP::payload is presented as a string. What could be used to reliably extract only host from Host header? To retrieve method and URI scan [TCP::payload] {%[^ /]%s} method uri seems to be working ok Now the question is if findstr and scan methods are correct here, or it could be implemented more elegant/efficient? Piotr204Views0likes0Comments