Forum Discussion

JQB's avatar
JQB
Icon for Nimbostratus rankNimbostratus
Jul 30, 2020

irule pool selection based on host AND path

Below is my current irule, which sends all requests with "/up/*" in the path to the faweb pool, otherwise, requests are sent to the default web pool.

when HTTP_REQUEST {
  switch -glob [string tolower [HTTP::path]] {
    "/up/*" { pool faweb }
  default { pool web }
  }
}

I am looking to modify the rule so that only specific hosts with "/up/*" in the path will go straight to the default web pool.

Example;

https://host1.website.com/up/foo.txt

https://host2.website.com/up/bar.txt

https://host3.website.com/up/dog.txt

should all go directly to default web pool

AND

https://host7.website.com/up/apple.txt

https://host8.website.com/up/orange.txt

https://host9.website.com/up/banana.txt

and any other hose not listed in the first list above (host1, host2, host3)

should all go to the faweb pool

  • Hi JQB,

    when HTTP_REQUEST {
    	switch [string tolower [HTTP::host]] {
    		"host1.website.com" -
    		"host2.website.com" -
    		"host3.website.com" { pool web }
    		default {
    			switch -glob [string tolower [HTTP::path]] {
    				"/up/*" { pool faweb }
    				default { pool web }
    			}
    		}
    	}
    }
  • Hi JQB,

    when HTTP_REQUEST {
    	switch [string tolower [HTTP::host]] {
    		"host1.website.com" -
    		"host2.website.com" -
    		"host3.website.com" { pool web }
    		default {
    			switch -glob [string tolower [HTTP::path]] {
    				"/up/*" { pool faweb }
    				default { pool web }
    			}
    		}
    	}
    }
    • JQB's avatar
      JQB
      Icon for Nimbostratus rankNimbostratus

      Worked like a charm. Thank you.