Forum Discussion

Chris_Broomes's avatar
Chris_Broomes
Icon for Altostratus rankAltostratus
Nov 21, 2013

Multiple pool and uri selections

I have a VIP that I am trying to do a couple of things with. 1. For HTTP traffic that meets a certain criteria I need to redirect my clients to different pools

 

  1. For other HTTP traffic I need to modify the destination URIs based on the requesting URIs.

So here's what I came up with:

 

(when HTTP_REQUEST {

 

if {[HTTP::uri] starts_with "/dam-ws"} {

 

pool abc.xyz_8102

 

HTTP::uri "/dam-ws$1"

 

}

 

elseif {[HTTP::uri] starts_with "/ArtesiaVideo"}{

 

pool abc.xyz_8554

 

HTTP::uri "/ArtesiaVideo$1"

 

}

 

elseif {[HTTP::uri] starts_with "/teams/MetadataEditor"}{

 

pool abc.xyz_11090

 

HTTP::uri "/teams/MetadataEditor.do$1"

 

}

 

elseif {[HTTP::uri] starts_with "/mac/plain/recentlyUpdatedCompaigns"}{

 

pool abc.xyz_8088

 

HTTP::uri "/mac/plain/recentlyUpdatedCompaigns$1"

 

}

 

elseif {[HTTP::uri] starts_with "/media-portal/displayLink.action"} {

 

HTTP::uri "/mac/mp/asset/viewSearchBasket.htm$1"

 

}

 

elseif {[HTTP::uri] starts_with "/media-portal/download"} {

 

HTTP::uri "/mac/mp/download/a.htm$1"

 

}

 

elseif {[HTTP::uri] starts_with "/media-portal/displayAsset.action"} {

 

HTTP::uri "/mac/mp/download/asset/master.htm$1" } }

 

Will this do the trick?

 

1 Reply

  • You could also use a switch:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "/dam-ws*" {
                pool abc.xyz_8102
                HTTP::uri "/dam-ws$1"
            }
            "/artesiavideo*" {
                pool abc.xyz_8554
                HTTP::uri "/ArtesiaVideo$1"
            }
            "/teams/metadataeditor*" {
                pool abc.xyz_11090
                HTTP::uri "/teams/MetadataEditor.do$1"
            }
            "/mac/plain/recentlyupdatedcompaigns*" {
                pool abc.xyz_8088
                HTTP::uri "/mac/plain/recentlyUpdatedCompaigns$1"
            }
            "/media-portal/displayLink.action*" {
                HTTP::uri "/mac/mp/asset/viewSearchBasket.htm$1"
            }
            "/media-portal/download*" {
                HTTP::uri "/mac/mp/download/a.htm$1"
            }
            "/media-portal/displayAsset.action*" {
                HTTP::uri "/mac/mp/download/asset/master.htm$1"
            }
        }
    }
    

    Or you could use a data group. Something like this:

    when HTTP_REQUEST {
        if { [class match [string tolower [HTTP::uri]] starts_with uri_dg] } {
            set path_pool [split [class match -value [string tolower [HTTP::uri]] starts_with uri_dg] ","]
            HTTP::uri [lindex $path_pool 0]
            if { [llength $path_pool] > 1 } {
                pool [lindex $path_pool 1]
            }
        }
    }
    

    where uri_dg is a string-based data group that concatenates the URI and pool. Example:

    /dam-ws := /dam-ws$1,abc.xyz_8102
    /artesiavideo := /ArtesiaVideo$1,abc.xyz_8554
    /teams/metadataeditor := /teams/MetadataEditor.do$1,abc.xyz_11090
    /mac/plain/recentlyupdatedcompaigns := /mac/plain/recentlyUpdatedCompaigns$1,abc.xyz_8088
    /media-portal/displayLink.action := /mac/mp/asset/viewSearchBasket.htm$1
    /media-portal/download := /mac/mp/download/a.htm$1
    /media-portal/displayAsset.action := /mac/mp/download/asset/master.htm$1