cancel
Showing results for 
Search instead for 
Did you mean: 

Select Pool based on host header

SOLVED
pro34log
Occasional Contributor

Select Pool based on host header

I am using the method suggested by this post https://splash.riverbed.com/docs/DOC-1249#comment-1032 but I am getting warning error, "Rule references an unknown pool via pool.activenodes" Here is my rule:   I spoke to support briefly and they suggested that this is happening when someone connected to the Virtual Server with a hostheader that didn't match the ones in my rule.  They also suggested I add a statement between the poolmap, and assigning the activenode, by evaluating if $pool string length = 0 to assign the default pool.

$hh = http.getHostHeader();

$poolmap = [

    "start.rs.com" => "p_RCD_prod.start.rs.com_http",

    "www.rs.com" => "p_RCD_prod.rs.com_http",

    "rs.com" => "p_RCD_prod.rs.com_http",

    "prod.rs.com" => "p_RCD_prod.rs.com_http",

    "authentication.rs.com" => "p_RCD_prod.authentication.rs.com_http",

    "service.rs.com" => "p_RCD_prod.services.rs.com_http",

    "reports.rs.com" => "p_RCD_prod.reports.rs.com_http"

];

$pool = $poolmap[ $hh ];

if( pool.activeNodes( $pool ) >= 1 ) pool.use( $pool );


I spoke to support breifly and they suggested that this is happening when someone connected to the Virtual Server with a hostheader that didn't match the ones in my rule.  They also suggested I add a statement between the poolmap, and assigning the activenode, by evaluating if $pool string length = 0 to assign the default pool.


I am a little lost and any suggestions would be very helpful.

1 ACCEPTED SOLUTION

Accepted Solutions
owen
Frequent Contributor

Re: Select Pool based on host header

Hi Arnold,

I've annotated the rule you provided with some comments - I hope that they make it clear.

If your rule encounters a host header that it does not recognise, it will set $pool to the empty string ("").  This will provoke the warning message you report, so I've added a test for that situation too.

regards

Owen


# Retrieve the host header provided by the client.  This is generally the domain name in the URL.


# The getHostHeader() function simplifies the host header, removing any port component,


# converting to lowercase, remove trailing '.', etc, so the result is unambiguous


$hh = http.getHostHeader();



# Now try to determine the webserver pool that serves requests for that host header


$poolmap = [


    "start.rs.com" => "p_RCD_prod.start.rs.com_http",


    "www.rs.com" => "p_RCD_prod.rs.com_http",


    "rs.com" => "p_RCD_prod.rs.com_http",


    "prod.rs.com" => "p_RCD_prod.rs.com_http",


    "authentication.rs.com" => "p_RCD_prod.authentication.rs.com_http",


    "service.rs.com" => "p_RCD_prod.services.rs.com_http",


    "reports.rs.com" => "p_RCD_prod.reports.rs.com_http"


];


$pool = $poolmap[ $hh ];



# If $pool is empty, that's because the hostheader $hh did not match a key in $poolmap


# Let's return an error (404 is typical for an unrecognized host header)


if( $pool == "" ) {


   http.sendResponse( "404 Not Found", "text/plain", "Unrecognised host ".$hh, "" );


}



# If none of the nodes in the pool are functioning, the pool will return an error.  We can


# test this and return a different error if we want (Zeus users will recognize this message)


if( pool.activeNodes( $pool ) == 0 ) {


   http.sendResponse( "503 Unavailable", "text/plain", "No suitable nodes are available to serve your request", "" );


}



# Everything appears OK.  $pool contains the name of a valid, working pool.  Let's use it


pool.use( $pool );



View solution in original post

3 REPLIES 3
owen
Frequent Contributor

Re: Select Pool based on host header

Hi Arnold,

I've annotated the rule you provided with some comments - I hope that they make it clear.

If your rule encounters a host header that it does not recognise, it will set $pool to the empty string ("").  This will provoke the warning message you report, so I've added a test for that situation too.

regards

Owen


# Retrieve the host header provided by the client.  This is generally the domain name in the URL.


# The getHostHeader() function simplifies the host header, removing any port component,


# converting to lowercase, remove trailing '.', etc, so the result is unambiguous


$hh = http.getHostHeader();



# Now try to determine the webserver pool that serves requests for that host header


$poolmap = [


    "start.rs.com" => "p_RCD_prod.start.rs.com_http",


    "www.rs.com" => "p_RCD_prod.rs.com_http",


    "rs.com" => "p_RCD_prod.rs.com_http",


    "prod.rs.com" => "p_RCD_prod.rs.com_http",


    "authentication.rs.com" => "p_RCD_prod.authentication.rs.com_http",


    "service.rs.com" => "p_RCD_prod.services.rs.com_http",


    "reports.rs.com" => "p_RCD_prod.reports.rs.com_http"


];


$pool = $poolmap[ $hh ];



# If $pool is empty, that's because the hostheader $hh did not match a key in $poolmap


# Let's return an error (404 is typical for an unrecognized host header)


if( $pool == "" ) {


   http.sendResponse( "404 Not Found", "text/plain", "Unrecognised host ".$hh, "" );


}



# If none of the nodes in the pool are functioning, the pool will return an error.  We can


# test this and return a different error if we want (Zeus users will recognize this message)


if( pool.activeNodes( $pool ) == 0 ) {


   http.sendResponse( "503 Unavailable", "text/plain", "No suitable nodes are available to serve your request", "" );


}



# Everything appears OK.  $pool contains the name of a valid, working pool.  Let's use it


pool.use( $pool );



pro34log
Occasional Contributor

Re: Select Pool based on host header

Owen thank you for your reply and insight.  I am still getting the same warning message after these changes.  Is there a way to have this not log a warning message?

owen
Frequent Contributor

Re: Re: Select Pool based on host header

Hi Arnold,

The warning message "Rule references an unknown pool via pool.activenodes" is emitted by the TrafficScript function 'pool.activenodes( $pool )'.

In the code above, $pool should only be either:

  • one of the values in $poolmap ("p_RCD_prod.start.rs.com_http", "p_RCD_prod.rs.com_http", etc), or...
  • the empty string

Line 20-21 in the code captures the empty-string possibility and terminates the rule by sending a response immediately to the client.

This suggests that one of the values in $poolmap is incorrect - it does not correspond to the name of a pool in your configuration.  Perhaps there is a typo or mismatch in your config?

It's unfortunate that the error message does not contain the name of the pool that does not exist.  If you can't determine which value (if any) is wrong, then you could insert this line just before line 26 where you call 'pool.activenodes( $pool )':


log.info( "Checking pool '" . $pool . "'" );


This will log the name of the pool, and when you next see the 'unknown pool' error in your log, look for the 'Checking pool' message next to it to find the name of the pool.

regards

Owen