Forum Discussion

Richard_Grigsby's avatar
Richard_Grigsby
Icon for Nimbostratus rankNimbostratus
Jun 03, 2015

iRule to read URI then point to the desired pool

I have a requirement to read a URL where the host and port are static https:/// But the URI changes. Based on the URI, I need to load balance to a server pool answering tcp/8443 or tcp/8444, or tcp/8445.

 

I have created an iRule that is already recognizing the URI and forwarding to the correct server pool. The HTTP page completes as long as the request is forwarded on to the 8443. If the URI match send the client to either the 8444 or 8445 pool, I get an HTTP 404 error.

 

No using the VIP by HTTPS directly to the pool node IP, on the redirected port number works.

 

Here is a copy of the iRule that is working to send sessions to the correct pool based on the uri.

 

Please give me some direction as to what I need to do to correct the HTTP 404 error.

 

when HTTP_REQUEST { switch -glob [HTTP::uri] { "/ent-inventory-services" { pool pools_sss_dev_8443 } "/ent-customer-services" { pool pools_sss_dev_8443 } "/ent-security-services" { pool pools_sss_dev_8443 } "/ent-payment-services" { pool pools_sss_dev_8443 } "/ent-agreement-services" { pool pools_sss_dev_8443 } "/ent-misc-services" { pool pools_sss_dev_8443 } "/ent-ht-services" { pool pools_sss_dev_8444 } "/customer" { pool pools_sss_dev_8445 } "/inventory*" { pool pools_sss_dev_8445 } "/agreements" { pool pools_sss_dev_8445 } "/ent-exception-services" { pool pools_sss_dev_8445 } "/payment" { pool pools_sss_dev_8445 } "/ent-report-services" { pool pools_sss_dev_8445 } default { Default - not matching any URI pool pools_sss_dev_default } } }

 

1 Reply

  • Make sure you have oneconnect on for your virtual server. If not, it will only make a load balancing decision on the first message on a connection.

     

    The iRule looks fairly good (although try to wrap in in a code block to display a little cleaner). This is a proper use of switch over if statements, although you may want to switch to [HTTP::Path] and wrap the HTTP::uri/path with a [string tolower] block to make sure case issues don't bugger this up. You may also want to look at the ProxyPass iRule for something that does this out of the box.

     

    when HTTP_REQUEST { 
        switch -glob [HTTP::uri] { 
            "/ent-inventory-services" { pool pools_sss_dev_8443 } 
            "/ent-customer-services" { pool pools_sss_dev_8443 } 
            "/ent-security-services" { pool pools_sss_dev_8443 } 
            "/ent-payment-services" { pool pools_sss_dev_8443 } 
            "/ent-agreement-services" { pool pools_sss_dev_8443 } 
            "/ent-misc-services" { pool pools_sss_dev_8443 } 
            "/ent-ht-services" { pool pools_sss_dev_8444 } 
            "/customer" { pool pools_sss_dev_8445 } 
            "/inventory*" { pool pools_sss_dev_8445 } 
            "/agreements" { pool pools_sss_dev_8445 } 
            "/ent-exception-services" { pool pools_sss_dev_8445 } 
            "/payment" { pool pools_sss_dev_8445 } 
            "/ent-report-services" { pool pools_sss_dev_8445 } 
            default {  Default - not matching any URI pool pools_sss_dev_default } 
        } 
     }