Help with irule using switch
I need an irule that does the following - If host name equals xxx.com and uri equals /yyy redirect to xxy.com.... but I need to switch between 6 different URIs - I want to use the SWITCH command but I'm not sure how to combine it with the first condition... (The host is constant). ThanksSolved1.8KViews0likes10CommentsiRule redirect based on uri or user-agent match logic.
Hello, looking for some direction here. I am trying create a rule which will match a specific set of uri and redirect if true to a prefered site and quit processing the irule. If the uri doesn't match, it will continue to the next match test for mobile in the header user-agent. If a match is found the redirect is to an other site. Problem is, I can match the uri, but if it doesn't match the uri it doesn't seem to continue nor match when the user-agent is mobile. Can someone tell me what I'm doing wrong here. I hope the formatting looks correct. Thanks.... ///pvr when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/about_news" - "/*.pdf" { HTTP::redirect "https://www.mysite.com[HTTP::uri]" } } switch -glob [string tolower [HTTP::header User-Agent]] { "*mobile*" { HTTP::redirect "https://www.myothersite.com[HTTP::uri]" } } }648Views0likes4CommentsStop processing iRule by referencing a variable
I've set a variable in iRule named "stop_rule_processing" and its value is set to 1 if a particular iRule has a hit: priority 300 when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/staging" } { if { !([matchclass [IP::client_addr] equals IP_private_access])} { log local0. "Source address [IP::client_addr] not from Private pool, session discarded" } { discard set stop_rule_processing 1 } } } The other iRule check if that variable is set to 1 and if it is i want to use "event disable" stop rule processing immediately: when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/staging*" { log local0. "PreProd URL detected from [IP::client_addr] , sending to preprod pool" pool PL-staging-pool } "/production*" { log local0. "Prod URL detected [IP::client_addr] , sending to prod pool" pool PL-production-pool } } } However I don't know how to check that variable at the beginning of second rule. I've tried to use multiple syntax versions of "if" command but can't get the syntax right.741Views0likes10CommentsPortion of iRule not being processed
I have combined multiple iRules into one, however the 2nd portion of the rule is not working. I have confirmed using logging that the URI is being caught, however redirection is not taking place. I believe I may not be nesting switch statements correctly. I have commented which parts of the script are working, and which section is not. Can anyone point me in the right direction? when HTTP_REQUEST { These DO work if { ([HTTP::host] equals "olddomain.com") } { switch -glob [HTTP::host] { "/" { HTTP::redirect "http://newdomain.com" } default { HTTP::redirect "http://newdomain.com[HTTP::uri]" } } } These do NOT work switch -glob [string tolower [HTTP::host]] { "oldforum.olddomain.com" { Check the URI, set to lowercase switch [string tolower [HTTP::query]] { "TID=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=posts&t=[URI::query [HTTP::uri] TID]" return } "FID=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=topics&f=[URI::query [HTTP::uri] FID]" return } "C=" { HTTP::redirect "https://newforum.newdomain.com/default.aspx?g=forum&c=[URI::query [HTTP::uri] C]" return } } } These DO work "*newdomain.com" - "*olddomain.com" { switch -glob [string tolower [HTTP::uri]] { "/someuri" { HTTP::redirect "http://newdomain.com/path-to/page.aspx" return } "/someuri2" { HTTP::redirect "http://http://newdomain.com/path-to/page.aspx" return } } } } }685Views0likes25CommentsiRule Switch/If/Else | using cookie name
Hello! Question 1 I am looking for a way to use the "switch" option (instead of an if/else condition) when a certain cookie name is present. For example: switch [HTTP::cookie name] { "CookieOne" { do something... } "CookieTWO" { do something else... } default { do something else else... } } .... [HTTP::cookie name] <- in singular (not names) Question 1 In case I use an if/else statement, is it possible to "lowercase" the cookie name and query the condition? For example: if { [ string tolower [HTTP::cookie] exists "JSESSIONID" ] } {....... Please advise J328Views0likes1CommentMultiple Switch statements in a single iRule
Hi there, I have several ranges of addresses which I want to see if traffic is coming from and deny traffic. Say the ranges are as follows as an example: 10.11.0.0/16 10.12.0.0/16 10.13.13.0/22 10.14.14.0/22 10.23.23.0/24 10.24.24.0/24 I am wondering if I can have multiple switch statements in the CLIENT_ACCEPTED section of code such as (obviously some default statement would need to be added somewhere along the line or an overarching check to bypass this lookup if it is not required): when CLIENT_ACCEPTED { switch -glob [IP::addr [IP::client_addr]/16] { "10.11.0.0" { some action } "10.12.0.0" { some action } } switch -glob [IP::addr [IP::client_addr]/22] { switch -glob [IP::addr [IP::client_addr]/22] { "10.13.13.0" { some action } "10.14.14.0" { some action } } switch -glob [IP::addr [IP::client_addr]/24] { switch -glob [IP::addr [IP::client_addr]/22] { "10.23.23.0" { some action } "10.24.24.0" { some action } } }Solved916Views0likes9Comments