Forum Discussion
Faruk_AYDIN
Oct 09, 2017Nimbostratus
Change 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
}
}