Forum Discussion
HTTP::URI redirect to another Pool
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "content1" } {
pool content_pool_1
} elseif { [HTTP::uri] starts_with "/abc" } {
pool abc_servers
}
}
The idea being that:
for users browsing to www.website.com/content1 >> they go to the content_pool_1 servers, everything else goes to content_pool_2 servers
But after I enable the rule, I keep getting 404 errors in server in content_pool_2.
The Virtual Server currently points to content_pool_2... how do I/do I need to somehow point the Virtual Server to both content_pool_1 and content_pool_2?
Right now, content_pool_1 isn't assigned to a Virtual Server... does it need to be?
Doesn't seem like this should be so difficult...
- hoolio
Cirrostratus
You could add logging to see exactly what's happening. You can also use a switch statement if you plan on adding more cases to the iRule:when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]" switch -glob [HTTP::uri] { "*content1" { pool content_pool_1 log local0. "[IP::client_addr]:[TCP::client_port]: matched content1. Pool: [LB::server]" } "/abc*" { pool abc_servers log local0. "[IP::client_addr]:[TCP::client_port]: matched abc. Pool: [LB::server]" } default { log local0. "[IP::client_addr]:[TCP::client_port]: default. Pool: [LB::server]" log local0. "No match" } } } when SERVER_CONNECTED { Debug logging only. Remove this event once done testing log local0. "[IP::client_addr]:[TCP::client_port]: server: [LB::server], [IP::server_addr]:[TCP::server_port]" }
- MeAndMyBIGIP_60
Nimbostratus
Thanks Hoolio... - Michael_Yates
Nimbostratus
What your wanting can be done several ways.when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
when HTTP_REQUEST { if {[TCP::local_port] == 80 } { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } elseif {[TCP::local_port] == 443 } { pool Content_Pool_1 } }
- hoolio
Cirrostratus
I think Michael's suggestion of one HTTP VS with the redirect of all requests to HTTPS and then a separate HTTPS VS with a separate pool switching iRule, will be the simplest to configure and administer. - MeAndMyBIGIP_60
Nimbostratus
Well There's yer problem!when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] }
when HTTP_REQUEST { if { ([HTTP::uri] starts_with "/Content")} { pool Content_Pool } }
- hoolio
Cirrostratus
If the pool members have a route back to the client through LTM, you can avoid using SNAT and LTM won't translate the source IP to its own address on serverside connections. If the pool members don't have LTM as their default gateway or the clients are on the same subnet as the pool members, you'll need to use SNAT. The simplest way to enable SNAT is to set SNAT to automap on the virtual server. - r_dynamo_79563
Nimbostratus
I need to create an iRule for an F5 build where the pool members are listening on a custom port (9200) for a VIP configured on port 80 that will load balance a web interface. Basically the intention is to redirect the HTTP request to one of the pool members on the custom port, and append a string of characters such as "/psp/maps/local" with the redirect to access a particular resource on the web interface. - nitass
Employee
are you looking for rewriting or redirection?[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:9200 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [HTTP::path] equals "/" } { pool foo HTTP::uri "/psp/maps/local" } } } [root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 or port 9200 New TCP connection 1: 172.28.20.11(59720) <-> 172.28.19.79(80) 1351654379.4628 (0.0012) C>S --------------------------------------------------------------- HEAD / HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.79 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(59720) <-> 200.200.200.101(9200) 1351654379.4648 (0.0018) C>S --------------------------------------------------------------- HEAD /psp/maps/local HTTP/1.1 User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.79 Accept: */* ---------------------------------------------------------------
- r_dynamo_79563
Nimbostratus
Suppose if I have "www.suppose.com" behind an F5 with two web servers (192.168.1.1 & 192.168.1.2) listening on port 9200. I want an iRule that will append "/psp/rewrite/redirection" to either pool members it intends to send load balance instance to "http://192.168.1.1:9200" or "http://192.168.1.2:9200" to get "http://192.168.1.1:9200/psp/rewrite/redirection" or http://192.168.1.2:9200/psp/rewrite/redirection , so that load balancing can be done for www.suppose.com/psp/rewrite/redirection without reserving separate VIP/DNS entries.
Or
"http://192.168.1.2:9200" append aforementioned string to get "http://192.168.1.2:9200/psp/rewrite/redirection" => www.suppose.com/psp/rewrite/redirection
- Mohamed_Lrhazi
Altocumulus
Did you try the iRule that nitass has given you?
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