Forum Discussion
jdewing
Cirrus
Nov 05, 2009URI Redirection
I'm new to IRule. I need to write a IRule to redirect to a specific server in the pool based on the path.
For example, https://Server1.com/ExportData should redirect to https://192.168.1.10/ExportData. The virtual server is setup for load balancing with 3 servers. Only one server will have the ExportData. How can I redirect to the specific node?
Thanks in advance
9 Replies
- The_Bhattman
Nimbostratus
If you want to redirect the client to a specific server then you could do the followingwhen HTTP_REQUEST { if { [HTTP::uri] eq "/ExportData" } { HTTP::redirect "http://192.168.1.10/[HTTP::uri]" } }
I hope this helps
CB - jdewing
Cirrus
Thanks for the quick response.
It did not worked..I'm getting page cannot be found, that is because it connected to the other server (Load Balance) that don't have the export directory. Only of the server in the LB scheme have the export directory.
http://192.168.1.10 is the private IP address, so I think the F5 is connected to the server with private IP address; but not able to route back out to the public virtual ip address. I don't know if i'm making sense here.
Is there anyway we can redirect based on the node or possible create a separate pool for it? - The_Bhattman
Nimbostratus
I misunderstood what you meant. If you mean forwarding to a specific node then you can do the followingwhen HTTP_REQUEST { if { [HTTP::uri] eq "/ExportData" } { node 192.168.1.10 80 } }
CB - jdewing
Cirrus
No luck! We are using https. I tried changed it to 443, still no luck. - The_Bhattman
Nimbostratus
What about the followingwhen HTTP_REQUEST { if { [HTTP::uri] contains "ExportData" } { node 192.168.1.10 443 } } - jdewing
Cirrus
CB,
Thanks for your help. You put me in the right direction. I got it working.. here what I did..
************************
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri contains "exportdata" } {
pool Servers_Pool member 192.168.1.10 80
}
}
*************************
i used "string tolower" because of the case sensitive issues.
Jamie - hoolio
Cirrostratus
Do you want to check the path (HTTP::path) or the query string (HTTP::query) for the exportdata string? The path is the URI minus the query string.
You could eliminate the intermediate variable, uri:when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "exportdata" } { pool Servers_Pool member 192.168.1.10 80 } }
Aaron - The_Bhattman
Nimbostratus
To add the elimination of a variable that Aaron stats will in the long run execute the code faster. In this case it's more or less for simplicity. - jdewing
Cirrus
Thank Aaron & CB
I eliminated the variable statement. It is working just the way I wants.
Many thanks
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
