Forum Discussion
need http redirect and then pool selection based on local port
-a user goes to http://page.example.com
-they get redirected to https://page.example.com/URI_Path and use pool1
however, one of the applets within https://page.example.com/URI_Path sends the user a redirect with a location of: http://page2.example.com:8003/newURI_Path. This applet is served off a different node/member listening on port 8003.
so my solution was to create an iRule as follows:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://page.example.com/URI_Path"
pool pool1
}
if { [TCP::local_port] equals 8003} {
HTTP::redirect "https://page.example.com/newURI_Path"
pool pool2
}
}
Where pool2 is the backend server listening on port 8003.
I'm sure there's a cleaner way to do this and I'd love any better ideas... But for now, I can't even get the 1st portion of the irule to work. I get the redirect, but it never goes to the pool. Note that I do not have any default pool set in my HTTPS virtual server.
Thanks
- MiLK_MaNNimbostratusYou can't set a redirect AND send traffic to a pool, they are mutually exclusive.
- gh0std0g_79292NimbostratusThanks for the response but I'm still having trouble... The goal is this... Initially, yes, we want to append a path to a hostname...
So when users come to somewhere.domain.com, I want to send them to somewhere.domain.com/here and I want them to use poolA
While the users are navigating around somewhere.domain.com/here, they may click on an applet that sends them a redirect to a different backend server which I've configured as a separate pool member (poolB)... So my thinking was, when the client receives this redirect, my iRule would send them to poolB.
Here's what my iRule looks like now and it's not working...
when HTTP_REQUEST {
if { [HTTP::uri] contains "configurator" } {pool poolB}elseif { [HTTP::uri] equals "/" } {HTTP::uri "/QITF/faces/portal"pool poolA}}
The redirect the client receives is something to the effect of somewhere.domain.com:8003/configurator. I was thinking of either using "URI contains" or "TCP local port equals"
And I do not have a default pool set up on this VS.
- hooleylistCirrostratusYou will probably want to add a default case to the iRule else you risk dropping requests for URIs which don't contain configurator or are exactly /. You can also use a switch statement to check the URI.
when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]" switch -glob [HTTP::uri] { "*configurator*" { pool poolB log local0. "[IP::client_addr]:[TCP::client_port]: Matched configurator, selecting poolB" } "/" { HTTP::uri "/QITF/faces/portal" pool poolA log local0. "[IP::client_addr]:[TCP::client_port]: Matched /, selecting poolA" } default { pool poolX log local0. "[IP::client_addr]:[TCP::client_port]: Matched default, selecting poolX" } } } when HTTP_RESPONSE { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::status] from [LB::server] (redirect? [HTTP::header Location])" }
Recent Discussions
Related Content
* 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