irule redirection
13 TopicsIrule to redirect based on specific URI
A request comes in as host:x.x.x.x/path_1/VMRCConsole.html or path_1/WebMKSConsole.html and for some reason hits the "default" in this rule instead of the specific statement that is intended to redirect to the correct pool. Can someone tell me what I am missing? The majority of this rule works perfectly. path_1 is the same path in all of these statements so that may be part of the problem. The reason for the rule is that we do not want user to be able to go to /path_1 without specific URI on the end of it. when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { “/unique*” { SSL::disable serverside pool pool_b log local0. "[IP::client_addr] with URI of [HTTP::uri] went to pool_b } "path_1/WebMKSConsole.html" { pool pool_A } "path_1/org/*" { pool pool_A } "path_1/VMRCConsole.html" { pool pool_A } "path_1/support/*" { pool pool_A } "path_1/amf/*" { pool pool_A } "/transfer/*" { pool pool_A } default { HTTP::redirect "https://some.page.for.redirects log local0. "Source IP address for connection to node: [IP::client_addr] [HTTP::uri]" } } }188Views0likes1CommentRedirect based on datagroup
I have an iRule which checks to see if the URI is listed within a datagroup and then does a redirect to the value for that URI within the datagroup. Now the customer would like it to check for the URI plus a trailing / (e.g. /redirectme/ as well as /redirectme ) but the data group list only contains the URI's without the trailing /. The data group has hundreds of entries so adding all the URI's again including the / is out of the question. My iRule is currently: if { [class match [HTTP::uri] eq datagroup_uri_list] } { HTTP::respond 302 Location "[class match -value [HTTP::uri] eq datagroup_uri_list]" } What would be the best way to add a / to the end of the datagroup_uri_list entries so they can be compared to the URI? I assume it'll be something like: if { [(class match [HTTP::uri] eq datagroup_uri_list] || class match [HTTP::uri] eq datagroup_uri_list]+/ } { HTTP::respond 302 Location "[class match -value [HTTP::uri] eq datagroup_uri_list]" }525Views0likes3Commentsredirect back to client ONLY IF URI contains /apps
I want to create an irule redirect that would only be sent back to the client if the URI contains a "/apps". For example, if user browsers to site1.abc.com...traffic is handled normally by F5 and sent to site1 pool, if user browses to site1.abc.com/assets...traffic is handled normally by F5 and sent to site1 pool. But if user browses to site1.abc.com/apps, then I want the irule to send back redirect to client to go to site2.abc.com/apps. Below is a simple redirect irule that I got from DevCentral...and I modified it a bit to fit my situation. Would this irule redirect the client's request for "site1.abc.com/apps" to "site2.abc.com/apps" ? when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site1.abc.com/apps" } { HTTP::redirect "http://site2.abc.com/apps" } }271Views0likes1CommentCan someone help me with iRule redirects?
Hi All! I am new to F5 and iRules. I'm helping out a client of mine to do redirections. I understand that if I want to redirect several URL's from an old domain to a new one, i will do as this: when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "www.old-example.com" and [HTTP::path] eq "/my-old-path/page-y" } { HTTP::respond 301 Location "https://www.new-example.com/new-path/page-x" } if { [string tolower [HTTP::host]] eq "www.old-example.com" and [HTTP::path] eq "/my-old-path-2/page-zz" } { HTTP::respond 301 Location "https://www.new-example.com/new-path-2/page-zzy" } if { [string tolower [HTTP::host]] eq "www.old-example.com" and [HTTP::path] eq "/my-old-path-n/old-page-n" } { HTTP::respond 301 Location "https://www.new-example.com/new-path-n/new-page-n" } } Can some of you experts out there confirm that the rules above are correct for simple redirections? Since I will also need to do wildcard redirections as in redirected to , can you help me out with a basic redirect rule for regex redirections? The wildcard redirections will always have some numbers in the end (page) that change, but else it will always be a quite static slug. Can you help me? Thank you so much for your time! Br, Tom252Views0likes1CommentiRule TLSv1.2 Redirect Page
I've created an iRule that builds out the redirect page we want to send people to if there browser isn't using TLSv1.2 and it works if I hit the url directly i.e. https://www.oursite.com or by typing something like https://www.oursite.com/locations/gohere. However, if I do a google search and click on the link from the search results for https://www.oursite.com/locations/gohere it will redirect to my TLSv1.2 page but the images don't display. if I view the link of an image it says https://www.oursite.com/locations/gohere/logo.png. Is there a way to handle this so if someone does do a google search and clicks on a link, the redirect page along with the images will display no matter where the page they are trying to get to is in the site structure? Here's the iRule code: when HTTP_REQUEST { if { [SSL::cipher version] ne "TLSv1.2" } { log local0. "Client from IP: [IP::client_addr] is using [SSL::cipher version], which is not TLS1.2 so redirected to maintenance page" switch [HTTP::uri] { "/fceLogo.png" { HTTP::respond 200 content [ifile get "fceLogo_png"] "Content-Type" "image/png" } "/fceHeader.jpg" { HTTP::respond 200 content [ifile get "fceHeader"] "Content-Type" "image/jpeg" } "/chromeLogo.png" { HTTP::respond 200 content [ifile get "chromeLogo"] "Content-Type" "image/png" } "/firefoxLogo.png" { HTTP::respond 200 content [ifile get "firefoxLogo"] "Content-Type" "image/png" } "/ieLogo.png" { HTTP::respond 200 content [ifile get "ieLogo"] "Content-Type" "image/png" } "/safariLogo.png" { HTTP::respond 200 content [ifile get "safariLogo"] "Content-Type" "image/png" } "/fceFooterLogo.png" { HTTP::respond 200 content [ifile get "fceFooterLogo"] "Content-Type" "image/png" } default { HTTP::respond 200 content [ifile get FarmCreditEastTLS ] "Content-Type" "text/html" } } } else { log local0. "The connection was initiated using TLSv1.2 and it was successful!!" } } Thanks.401Views0likes3CommentsiRule Redirect for the same URL?
Hello All, I am struggling to implement an iRule condition for the same URL where I can't use any redirects like 301, 302, 307, etc. because of infinite loop. Here is the example. Source URL: Destination URL: so basically I want to add /not/working/ part before hitting the backend servers. I tried few techniques but no results yet. Thanks as always, R578Views0likes1CommentiRule for URI/string manipulation
Hi, I need to perform some complex redirections on a VS due to sharepoint migration. Users are reaching my VS using an URL with a specific variable included, like f.ex.: I need to extract the object ID (1234 obviously) and push it in new URL: so the objid variable is trasnferred to q variable with OBJECT%1A inserted in the beggining; Also a legacy URL might appear: where 1234 should be treated same as objid Another variation might be a substitution from this: to still I'm not quite sure how to handle such string manipulation in iRule, especially that the lenght of variable q might differ from query to query, and when it is provided in text we can't be sure what it will be exactly... Any help appreciated :) thanks248Views0likes1Commentredirect to specific pool based on host
Hi, I am looking for a Irule to redirect trafic to a specific pool based on the incomming http request host. I have made the following but the Big IP gaves an error. when HTTP_REQUEST { if { [HTTP::host] == "linked.jan.nl" } { pool p_sfb_a } elseif { [HTTP::host] == "lyncdiscover.jan.nl" } { pool p_sfb_a } elseif { [HTTP::host] == "owas.jan.nl" } { pool p_sfb_a } else { pool Pool_none } } Anyone a idea to help me out? The pools are not jet in place. This is the message i get from the big-IP when i tried to save the irule. 01070151:3: Rule [/Common/mzi_sfb_redirect_based_on_host] error: /Common/mzi_sfb_redirect_based_on_host:4: error: [undefined procedure: elseif][elseif { [HTTP::host] == "lyncdiscover.maasstadziekenhuis.nl" } { pool p_sfb_a } ] /Common/mzi_sfb_redirect_based_on_host:10: error: [undefined procedure: else][else { pool Pool_none }]379Views0likes3Commentsirule To Redirect A Specific Network Going To a URL
I have an office in India and need to send any request from that network for site.domain.com to local.domain.com. If the network is not equal India_Host_Networks then hit site.domain.com. I think I have part of the irule, but need help finishing it. when HTTP_REQUEST { if { [class match [IP::client_addr] equals India_Host_Networks]) and ( [HTTP::host] equals "site.domain.com") } { HTTP::redirect " https://local.domain.com/stream/" } }488Views0likes9CommentsRules to redirect based on URL
Hi, I have a web application that is deployed on 3 servers also 3 URL's to them Server 1 (192.XXX.XXX.XXX) ==> http:\192.XXX.XXX.XXX\ Server 2 (192.XXX.XXX.YYY) ==> http:\192.XXX.XXX.YYY\ Server 3 (192.XXX.XXX.ZZZ) ==> http:\192.XXX.XXX.ZZZ\ I also have a public URL what given to me which is http://website.com/ I need to redirect different users to different servers based on a context on my public URL. When URL is http://website.com/User1 then redirect him to Server 1 http:\192.XXX.XXX.XXX\ When URL is http://website.com/User2 then redirect him to Server 2 http:\192.XXX.XXX.YYY\ When URL is http://website.com/User3 then redirect him to Server 3 http:\192.XXX.XXX.ZZZ\ But I dont have these contexts (User1,User2,User3) on my Servers 1,2 or 3.1.9KViews0likes2Comments