Forum Discussion

JP_G's avatar
JP_G
Icon for Altostratus rankAltostratus
Oct 22, 2020

iRule to use HEADER name and value to redirect bot traffic to a specific pool

We are looking for the detail: "X-APP-WHITELIST" in the header equal to "8" OR if the user-agent has, "googlebot" discovered in the header. Not looking at the XFF part of the header. Is there a better name than, "googlebot" to use?

Thank you all for your replies. This is awesome.

when HTTP_REQUEST {
	if { [HTTP::header exists X-APP-WHITELIST] and [HTTP::header X-APP-WHITELIST] equals "8" or [string tolower [HTTP::header User-Agent]] contains "googlebot" } {
		pool A
	}
	else {
		pool default
	}
}

2 Replies

  • lots of questions and some things i don't get in it.

     

    1) you say && but i dont see that later

     

    2) succinct is probably a typo, what do you mean exactly?

     

    the effect of logging will depend on the capacity of your box and how frequently your site is visited. you can start and see what happens, it will be hard to just say fine or not now.

     

    if you are looking to see if this accomplishes what you want why not just try, setup a test virtual server and send the requests via curl or postman or ... and look at the logging.

     

    if you want to know if there are better ways then ill leave that to others. one advise is to look at the iRule documentation and other examples.

     

    one thing though the { } around the log statement i don't get.

  • JP_G's avatar
    JP_G
    Icon for Altostratus rankAltostratus

     

    #1. sorry about that...just found an operator listed as "&&" and didnt think that was correct which why I used, "or".

    #2. edited out the succinct. was super rushed and just copied and pasted incorrectly.

    #3. took out the logging. just wanted it there to turn on or off in order to see hits in log but can easily CURL it to see if it is working.

     

    Does anyone have a better iRule suggestion in order to route traffic from one pool to another for bot traffic? Is there a better way to do this?