Forum Discussion
Al_s_296685
Nimbostratus
Oct 08, 2017F5 BIG-IP Irule - redirect to individual node for external monitoring
Hi all
I'm looking at implementing an external monitoring solution whereby we do something like the following
read the URI and see if it contains formatting like this "/monitoring/servername" ...
Faruk_AYDIN
Altostratus
Oct 09, 2017Change the second part(replace) of your irule like this :
when HTTP_REQUEST {
Check if path contains /monitoring
if {[HTTP::path] contains "/monitoring/"}{
use getfield to split the uri based on monitoring/ and then return the server name after that
set server_id [getfield [HTTP::uri] "monitoring/" 2 ]
log local0. "Server id: $server_id"
Replace /monitoring and servername in the path
set uri [string range [HTTP::uri] 0 [expr {[string first "/monitoring/" [HTTP::uri]] - 1}]]
log local0. "orginal part of uri: $uri"
HTTP::uri $uri
redirect or rewrite uri?
HTTP::redirect "http://[HTTP::host]$uri"
pool "/Common/${server_id}"
}
}
If I were you, I would use node ip (and w/o node port) instead of Server name, like this:
when HTTP_REQUEST {
Check if path contains /monitoring
if {[HTTP::path] contains "/monitoring/"}{
use getfield to split the uri based on monitoring/ and then return the node ip after that
set server_id [getfield [HTTP::uri] "monitoring/" 2 ]
log local0. "Node IP: $node_ip"
Omit /monitoring and nodeip in the path
set uri [string range [HTTP::uri] 0 [expr {[string first "/monitoring/" [HTTP::uri]] - 1}]]
log local0. "orginal part of uri: $uri"
HTTP::uri $uri
Send the request to the specified node
node $node_ip 80
}
}
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
