Forum Discussion
Xavier_113679
Nimbostratus
Aug 06, 2012Passing variable to http monitor
Hi, I'm trying to setup a monitor for a pool containing 3 members that will call a servlet located on a different server. Here's an idea GET /rsa_check?$NODE HTTP/1.1\nHost: server_hosting_s...
John_Lennon_457
Nimbostratus
Mar 23, 2010Hi Aaron,
we're close however there is an issue - most likely the way I've coded it.
when HTTP_REQUEST priority 501 {
if { [LB::server pool] eq $default_pool } {
set myURI "[HTTP::uri]"
HTTP::redirect "https://www.mysite.com/error.html"
HTTP::uri {/error_gh.html}
log local0.error "Redirecting user IP: [IP::client_addr] to /error.html, URI requested: $myURI $default_pool"
}
}
What I see is that this code is triggered after the previous HTTP_REQUEST changed the URI, for example because of this rule:
/catalog*" { HTTP::uri {/plugins/plugincatalog
What I see in the log is:
Rule Redirections : Redirecting user IP: 96.237.xxx.xxx to /error.html, URI requested: /plugins/plugincatalog Dummy_pool
What is the proper way of resolving this?
Thanks
- drteeth_127330Mar 08, 2005Historic F5 AccountThis feature has been requested several times and will be added to a subsequent version of the product. However, you can enforce the limit using iRules. I would prefer that you attempt to write the rule first, and I will help if you get stuck. You can use the session command to add an entry in the session table for each client IP. The session table will automatically expire old entries if you specify a timeout. If the limit is exceeded, you can reject the connection. Hope this helps.
- kanokwut_thanadMar 08, 2005
Nimbostratus
drteeh, - drteeth_127330Mar 08, 2005Historic F5 Account
- unRuleY_95363Mar 09, 2005Historic F5 AccountHere is a sample rule that uses cookies to track a given client and limit the total number of clients to 50. This rule uses a Tcl array to track the current clients:
rule session_limit { when RULE_INIT { array set ::active_sessions { } set ::total_active_clients 0 set ::max_active_clients 50 } when HTTP_REQUEST { if { not [info exists client_id] } { if { [HTTP::cookie exists "ClientID"] } { set client_id [HTTP::cookie "ClientID"] set need_cookie 0 } else { set client_id [string range [AES::key 128] 8 end] set need_cookie 1 } if { not [info exists ::active_sessions($client_id)] } { if { $::total_active_clients >= $::max_active_clients } { HTTP::redirect "http://yoursiteisdown.com/" return } incr ::total_active_clients set ::active_sessions($client_id) 1 } else { incr ::active_sessions($client_id) } } } when HTTP_RESPONSE { if { $need_cookie } { HTTP::cookie insert name "ClientID" value $client_id set need_cookie 0 } } when CLIENT_CLOSED { if { [info exists client_id] and [info exists ::active_sessions($client_id)] } { incr ::active_sessions($client_id) -1 if { $::active_sessions($client_id) <= 0 } { unset ::active_sessions($client_id) incr ::total_active_clients -1 } } } }
rule session_limit { when RULE_INIT { array set ::active_clients { } } when CLIENT_ACCEPTED { set client_ip [IP::remote_addr] if { [info exists $::active_clients($client_ip)] and $::active_clients($client_ip) > 10 } { log "Client $client_ip has too many connections" reject return } incr ::active_clients($client_ip) } when CLIENT_CLOSED { if { [info exists ::active_clients($client_ip)] } { incr ::active_clients($client_ip) -1 if { $::active_clients($client_ip) <= 0 } { unset ::active_clients($client_ip) } } } }
- hirox_127495Mar 24, 2005Historic F5 AccountThis code will work on 9.0.4...
when RULE_INIT { array set ::active_clients { } log local0. "phase1" } when CLIENT_ACCEPTED { set client_ip [IP::remote_addr] if { [info exists ::active_clients($client_ip)] } { if {$::active_clients($client_ip) > 10 } { log "Client $client_ip has too many connections" reject return } else { log local0. "$::active_clients($client_ip)" incr ::active_clients($client_ip) } } else { set ::active_clients($client_ip) 1 } } when CLIENT_CLOSED { if { [info exists ::active_clients($client_ip)] } { incr ::active_clients($client_ip) -1 if { $::active_clients($client_ip) <= 0 } { unset ::active_clients($client_ip) } } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects