Forum Discussion
Carolyn_Robert_
Nimbostratus
Dec 12, 2006Redirecting to a pool
I'm confused about how to use redirects and pooling.
Here's my situation:
> DNS entry "www.abcd.com" is pointed at my virtual server "gateway"
> VS "gateway" uses pool "PROD", that contains two nodes, "website1" & "website2"
> I need to actually redirect from http to https using the two nodes in the pool while at the same time modifying my URI.
Here's a piece of code:
when HTTP_REQUEST {
if { ([HTTP::host] equals "www.abcd.com") } {
HTTP::uri /xyz.html
pool PROD
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
The [HTTP::host] substitution does not work, because the host needs to be modifed by whichever node the pool picks. So my final URL would be either:
https://website1.abcd.com/xyz.html
OR
https://website2.abcd.com/xyz.html
depending on what the pool determines is the next available candidate for work.
How can I figure out what node is selected by the pooling function so that I can build the full URL for the redirect statement?
- hoolio
Cirrostratus
I don't think it will work to select the pool and redirect in the same shot.when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
when LB_SELECTED { if { [IP::addr [LB::server addr] equals 10.0.0.10] }{ HTTP::header replace Host "new_http_host_header.example.com" log local0. "Replaced host header with value 1" } elseif {[IP::addr [LB::server addr] equals 10.0.0.20] }{ HTTP::header replace Host "second_new_http_host_header.example.com" log local0. "Replaced host header with value 2" } else { take some default action? pool default_pool log local0. "Took some default action" } }
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