Forum Discussion
URL PATH based routing
Hi,
wondering if someone can help me here with a basic IRule that routes traffic to a particular pool based on matching a FQDN and URL path?
The reason for this is that the same FQDN is used for multiple services.
e.g. this is what I use in riverbed world but I have not cracked the Irules yet:
if(string.startsWITHl( http.getheader ( "Host" ), "abc.com" ) ){
if(string,contains(http.getpath(), "/test.svc")){
pool.use( "abc_pool" );
} else if(string,contains(http.getpath(), "/efg.svc")){
pool.use( "efg_pool" );
will really appreciate your help with this.
Regards,
14 Replies
- Snl
Cirrostratus
untested
when HTTP_REQUEST { switch [HTTP::host] { "abc.com" { switch -glob [HTTP::uri] { "/test.svc" { pool abc_pool } "/efg.svc" { pool efg_pool } } } } }
- Qasim
Cirrostratus
thanks Snl, just tested but I am getting the following error while saving it:
6: error: [undefined procedure:
- Snl
Cirrostratus
I haven't received any error while saving , which tmos version you are using
- Qasim
Cirrostratus
I am using :
Sys::Version
Main Package
Product BIG-IP
Version 12.1.3.5
Build 0.0.10
Edition Point Release 5
Date Mon May 21 17:36:20 PDT 2018
- Qasim
Cirrostratus
actually ignore me, I was making a typo in the rule. apologies
I will let you know once i have tested the service.
- Qasim
Cirrostratus
just wondering though, what would my Irule look like if I was to merge the following two Irules into one:
- when HTTP_REQUEST {
- switch [HTTP::host] {
- "abc.com"
- {
- switch -glob [HTTP::uri] {
- "/abc.svc" { pool abc_pool }
- }
- }
- }
- }
- when HTTP_REQUEST {
- switch [HTTP::host] {
- "efg.com"
- {
- switch -glob [HTTP::uri] {
- "/efg.svc" { pool efg_pool }
- }
- }
- }
- }
in the above two rules the fqdn is different as well
- Snl
Cirrostratus
i am using 12.1.3.4 and its accepting the code
- Qasim
Cirrostratus
Hi,
Apologies it was my bad. I was making a typo i the rule. so what's your though about the below:
what would my Irule look like if I was to merge the following two Irules into one:
- when HTTP_REQUEST {
- switch [HTTP::host] {
- "abc.com"
- {
- switch -glob [HTTP::uri] {
- "/abc.svc" { pool abc_pool }
- }
- }
- }
- }
- when HTTP_REQUEST {
- switch [HTTP::host] {
- "efg.com"
- {
- switch -glob [HTTP::uri] {
- "/efg.svc" { pool efg_pool }
- }
- }
- }
- }
in the above two rules the fqdn is different as well
- Snl
Cirrostratus
try below
when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "abc.com" and [HTTP::uri] contains "/abc.svc" } { pool abc_pool return if { [string tolower [HTTP::host]] eq "xyz.com" and [HTTP::uri] contains "/efg.svc" } { pool xyz_pool return } } }
- eehir
Nimbostratus
Probably something like this
when HTTP_REQUEST { switch [HTTP::host] { "abc.com" { switch -glob -- [HTTP::uri] { "/abc.svc" { pool abc_pool } } } "efg.com" { switch -glob -- [HTTP::uri] { "/efg.svc" { pool efg_pool} } } } }
- Qasim
Cirrostratus
thanks Eehir/SNL, I have tried this now, I will let you know once I have a confirmation.
much appreciated
- Qasim
Cirrostratus
.Hi Eehir,
Can you help out here please. your rule works as expected but the problem is that its locking it down to that specific path. any chance we can change rule to say the "starts with" if so, would that fix the problem? if so, how the rule would look like?
thanks in advance.
Regards,
- eehir
Nimbostratus
Hi,
Just add * to the end of the path, that should act as a starts with statement.
/abc.svc*
- Qasim
Cirrostratus
thanks guys,
the rule is working as expected but its locking it down to that specific path. any chance we can change this to e.g. "http path starts with" or contains? whatever you think is better
kind regards,
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