Forum Discussion

  • when HTTP_REQUEST {

     

    if [HTTP::header "User-Agent"] starts_with "user agent text"

     

    HTTP::redirect http://[getfield [HTTP::host] ":" 1][HTTP::uri]

     

    } else {

     

    pool

     

    }

     

    }
  • THanks for the quick response Dave, just for verification this will work for HTTPS redircet to HTTP correct?
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Yes, as long as it is applied to the HTTPS virtual server and the LTM is decrypting the traffic.

    Although if you want a 301, you'll have to use the HTTP::respond command instead of the HTTP::redirect command which sends a 302:
    when HTTP_REQUEST {
      if [HTTP::header "User-Agent"] starts_with "ua_text"
        HTTP::respond 301 "Location" "http://[getfield [HTTP::host] : 1][HTTP::uri]"
      } else {
        pool myPool
      }
    }
    HTH

    /deb
  • deb, i am just getting around to getting this added to my current irule and am clear on all but what is supposed to go in the "Location" field. I appreciate your help. Thank you.
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    The Location value in the iRule above will just redirect to same host, same URI over HTTPS, stripping off any non-standard port from the host header before re-using the value.

     

     

    Were you looking for something different?

     

     

    /deb
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi maynard -

    For the iRules Editor question, you should see if your question has already been addressed in that forum or post a new one if not: Click here

    As for your iRule, you can use a couple of class lists to clean this up quite a bit (I changed the order of a few things, so you'll want to review for accuracy):
    when HTTP_REQUEST {
      if { [HTTP::header "User-Agent"] contains "maynard" } {
         let test traffic in always
        pool RD
      } elseif { [HTTP::header "host"] starts_with "physicianreports.com" } {
         send permanent redirect to FQDN for this site only
        HTTP::respond 301 "Location" "http://www.physicianreports.com[HTTP::uri]"
      } elseif { [IP::addr [IP::client_addr] equals $::rejectAddrs] } {
         discard all requests originating from the addresses in the specified list
        discard
      } elseif { [HTTP::header "User-Agent"] contains $::bot_poolAgents) || \
       ([IP::addr [IP::client_addr] equals $::bot_poolAddrs)}{
         send all bots on the list to the bot pool
        pool bot_pool
      } elseif { [HTTP::uri] contains "ppgreports" } {
         send specific URIs to the appropriate pool
        pool ppgreports
      } elseif { [HTTP::uri] contains "/images" } {
         send specific URIs to the appropriate pool
        pool Media
      } elseif { [HTTP::uri] contains $::ConsumerURIs } {
         send URIs in the list to the Consumer pool
        pool Consumer
      } else {
        pool http_cluster1
      }
    }
    The rule will need the following 4 classes defined:

    class bot_poolAgents {
       type string
      "ScanAlert"
      "Slurp"
      "GoogleBot"
      "msnbot"
      "Becomebot"
      "Exabot"
      "psbot"
      "Verizon Superpages Web Crawler"
      "Voilabot"
      "Infocrawler-bot"
      "Nutch"
      "Baiduspider"
      "ContextAd Bot"
      "SpiderThread"
      "Gigabot"
      "Wotbox"
      "Girafabot"
      "NaverBot"
      "Jetbot"
      "WISEnutbot"
      "Fast Enterprise Crawler"
      "NLCrawler"
      "ZiggsBot"
      "ConveraCrawler"
      "NimbleCrawler"
      "FAST-Webcrawler"
      "MSIECrawler"
      "ichiro"
      "IRLbot"
      "accoona"
      "TurnitinBot"
      "genieBot"
      "majestic12"
      "sp.ask.com"
      "Fetch API Request"
      "Ask Jeeves/Teoma"
      "Healthbot"
      "TencentTraveler"
      "aipbot"
      "OpenWebSpider"
      "Help:Bot"
    }
    class bot_poolAddrs {
       type address
      network 66.249.64.0/20
      network 64.233.178.0/23
      network 64.41.168.240/28
      host 72.14.228.89
      host 65.57.245.11
      network 209.67.114.16/26
      host 69.20.123.42
      host 196.201.83.98
      host 38.119.107.78
    }
    class rejectAddrs {
       type address
      network 207.154.31.5/20
      host 213.255.196.85
    }
    class ConsumerURIs {  
       type string
      "/ajax"
      "www.physicianreports.com"
      "/health-management-tools"
      "/local-doctors-directory"
      "/doctors-directory"
      "dsp_ad_block.cfm"
      "consumer"
      "directory_search"
      "/directory"
    }

    HTH

    /deb
  • Maynard, for the iRules Editor issue, I did upload a new version to devcentral recently but that shouldn't have given a deployment error. What you can try to do is uninstall the Editor and download the latest install from DevCentral and rerun the installation.

     

     

    Let me know if that doesn't work for you.

     

     

    -Joe