http::respond
3 TopicsGeoIP iRule redirects with switch
Hi All, I'm trying to create an 'all-in-one' iRule to handle a few things at once. Firstly I need to allow a few whitelists through (CDN, office addresses etc) then based on the GeoIP location redirect to either a pool or a different domain. I have the iRule working in a sense but for a reason unknown to me, redirecting to pools doesn't work - and may be related to how I've laid out the iRule. I have to include the switch because some of the Virtual Servers this applies to will need 10+ redirect entries to different websites, as does the elseif statements displaying content from the relevant pools. Although, if this works in the switch statement that will be easier to manage but I've tried to include pools in the switch statement and again, no joy. Basically, if it's not CDN and it's not in the whitelist > Redirect to a new URL or an active Pool based on the client IP. when HTTP_REQUEST { set countries [whereis [IP::client_addr] country] if {[class match [string tolower [HTTP::header value "Via"]] contains CDN_HEADERS] } { return } elseif {[class match [IP::client_addr] equals Whitelist]} { return } elseif {($countries equals "NL")} { pool NL-splash } elseif {($countries equals "RU")} { pool RU-splash } else { switch [whereis [IP::client_addr] country] { "UK" { HTTP::respond 301 noserver Location "https://www.google.com" } "US" { HTTP::respond 301 noserver Location "https://www.google.com" } default { return } } } } Thanks288Views0likes3CommentsAPM: 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!504Views0likes8CommentsiRule - conflicting with IE
I have the following iRule which inserts headers for HSTS, checks 2 data group lists for "referer_check_filetypes" and "referer_allowed_hosts" - those are simply our websites and PDF file types which essentially allow the browser to download a PDF once a user is logged in, as long as they come from a website on the allowed hosts data group list. This iRule also forces SSL traffic. The issue we are experiencing is - when a user visits a page, they login, and a download is supposed to immediately happen. With this code, in Internet Explorer ONLY, a new tab opens up and the website's homepage is displayed. On the previous tab, the user is allowed to download the PDF. If I remove the referrer and file type checks within HTTP_REQUEST, everything works as designed. What's supposed to happen is - a new tab pops up and immediately closes, resulting in the PDF being downloaded. Without this code, the problem is that it results in people downloading PDFs without being logged in if they come from a search engine such as Google after performing a Google search for PDFs that were indexed on our websites. The expected behavior when a user tries to download a PDF via a Google search, they're redirected back to the homepage of the domain that was requested. site:ourwebsite.com filetype:pdf I've tried changing HTTP::respond 302 "Location" to HTTP::redirect, however that results in a "This page could not be displayed" Any ideas why a tab would pop up, and not disappear, confusing the user because they don't know their download link is on the previous tab? when RULE_INIT { set static::expires [clock scan 20110926] } when HTTP_RESPONSE { HTTP::header insert "Strict-Transport-Security" "max-age=15552000; includeSubDomains" } when HTTP_REQUEST { set refer_host [string tolower [URI::host [HTTP::header Referer]]] if { ( [class match [HTTP::path] ends_with referer_check_filetypes] ) and ( not [class match $refer_host contains referer_allowed_hosts] ) } { log local0. "[IP::client_addr]:[TCP::client_port]: hotlink detected from Referer: $refer_host for [HTTP::host][HTTP::uri]" HTTP::respond 302 "Location" "http://[HTTP::host]" Cache-Control No-Cache Pragma No-Cache } if {([string tolower [HTTP::host]] starts_with "www.")} { HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]" return } elseif { [TCP::local_port] == 80 } { HTTP::redirect https://[HTTP::host][HTTP::uri] return } }339Views0likes7Comments