Forum Discussion

Brian_69413's avatar
Brian_69413
Icon for Nimbostratus rankNimbostratus
Nov 06, 2012

Direct Server Access

I have the following iRule which seems to work at first, but then I see traffic to other pool members as well...not sure what I am missing here?

 

when RULE_INIT {

 

Log debug to /var/log/ltm? 1=yes, 0=no.

 

set ::debug_code 1

 

set ::server_direct 0

 

}

 

 

when HTTP_REQUEST {

 

Only apply rule if this request is coming from a internal addresses

 

if { [matchclass [IP::client_addr] equals $::internal_address_dg]} {

 

if { ([HTTP::uri] contains "?srv=") and ([HTTP::uri] contains "?port=") }{

 

set server_ip [URI::query [HTTP::uri] srv]

 

set server_port [URI::query [HTTP::uri] port]

 

set ::server_direct 1

 

 

if {$::debug_code}{log local0. "[IP::client_addr] is attempting to send [HTTP::host] traffic to $server_ip:$server_port"}

 

pool [LB::server pool] member $server_ip $server_port

 

}

 

}

 

}

 

 

when LB_FAILED {

 

If the selection fails and t

 

if {$::debug_code}{log local0. "Pool member selection failed, using default pool..."}

 

if { $::server_direct }{

 

HTTP::respond 200 content {

 

 

 

 

 

 

 

 

 

Invalid Direct Server Access: [HTTP::host][HTTP::uri]

 

 

 

 

}

 

}

 

}