Forum Discussion
Kevin_Leclercq_
Nimbostratus
Dec 05, 2005Irule to access individual web servers
We would like to implement the following if it is possible:
We go to www.website.com [192.168.1.100]
In BigIp VIP 192.168.1.100 points to pool: webfarm_80
Webfarm_80 Contains ...
Martin_Machacek
Dec 05, 2005Historic F5 Account
Kevin,
there are 2 ways how to achieve your desired behavior:
1) use direct node select expression in the pool,
2) create additional pools each containing one of your servers and use
rule to select pool based on matching the ip= pattern in
the URI,
Example configuration for solution 1:
pool webservers {
select node(findstr(http_uri, "ip=", 3, '/') + ":80")
member 10.10.10.1:80
member 10.10.10.2:80
member 10.10.10.3:80
member 10.10.10.4:80
member 10.10.10.5:80
}
virtual www.website.com:80 {
use pool webservers
} The solution assumes that the ip= portion is separated from the
actual URI by a slash (e.g. /ip=10.10.10.1/index.html). The disadvantage of this (otherwise elegant) solution is that the node select expression is evaluated on every request.
Example configuration for solution 2:
pool all_webservers {
member 10.10.10.1:80
member 10.10.10.2:80
member 10.10.10.3:80
member 10.10.10.4:80
member 10.10.10.5:80
}
pool webserver1 {
member 10.10.10.1:80
}
pool webserver2 {
member 10.10.10.2:80
}
pool webserver3 {
member 10.10.10.3:80
}
pool webserver4 {
member 10.10.10.4:80
}
pool webserver5 {
member 10.10.10.5:80
}
rule server_switch {
if(http_uri starts_with "/ip=") {
if(http_uri starts_with "/ip=10.10.10.1) {
use pool webserver1
} else
if(http_uri starts_with "/ip=10.10.10.2) {
use pool webserver2
} else
if(http_uri starts_with "/ip=10.10.10.3) {
use pool webserver2
} else
if(http_uri starts_with "/ip=10.10.10.4) {
use pool webserver2
} else
if(http_uri starts_with "/ip=10.10.10.5) {
use pool webserver2
} else
redirect to ""
}
} else {
use pool all_webservers
}
}
virtual www.website.com:80 {
user rule server_switch
}As you can see this approach has a little bit of scaling issue in case you need to select from large number of servers. On the other hand it has excellent performance because the more complicated logic is not invoked in the prevailing case, i.e. if no /ip= is specified in the URI (I'm assuming that the /ip= construct is for testing purposes, right?).
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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