Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

URL and URI Pool Selection iRule

I need help with an new irule. I want to check the URL for default http page and send to port 80 pools. All others will be matched on the URI section.

I have the URI section working but when adding in the new URL section the syntax is not correct.

The URL section can be added to the very bottom if needed after URI check.

*Updated irule using. LTM Still does not like the syntax

When HTTP_REQUEST { #check for URL and send to pool switch [string tolower [HTTP::host]] { "sam.testsite99.testing2.com" { pool sam.testsite99.testing2.com-80 }
"bob.testsite99.testing2.com" { pool bob.testsite99.testing2.com-80 } } when HTTP_REQUEST { switch -glob [HTTP::uri] { "/sam1" { SSL::disable serverside pool testsite99.testing2.com-8080 } "/bob1" { SSL::disable serverside pool bob.testsite99.testing2.com-8080 }
"/sam2" { SSL::disable serverside pool testsite99.testing2.com-8081 } "/bob2" { SSL::disable serverside pool bob.testsite99.testing2.com-8081 } "/sam3" { SSL::disable serverside pool testsite99.testing2.com-8085 } "/bob3" { SSL::disable serverside pool bob.testsite99.testing2.com-8085 } "/sam4" { SSL::disable serverside pool testsite99.testing2.com-9080 } "/bob4" { SSL::disable serverside pool bob.testsite99.testing2.com-9080 } "/sam5" { SSL::disable serverside pool testsite99.testing2.com-9081 } "/bob5" { SSL::disable serverside pool bob.testsite99.testing2.com-9081 } "/sam6" { SSL::disable serverside pool testsite99.testing2.com-9082 } "/bob6" { SSL::disable serverside pool bob.testsite99.testing2.com-9082 } "/sam7" { SSL::disable serverside pool testsite99.testing2.com-9085 } "/bob7" { SSL::disable serverside pool bob.testsite99.testing2.com-9085 } "/sam8" { SSL::disable serverside pool testsite99.testing2.com-22 } "/bob8" { SSL::disable serverside pool bob.testsite99.testing2.com-22 } "/sam9" { pool testsite99.testing2.com-443 } "/bob9" { pool bob.testsite99.testing2.com-443 } "/sam0" { pool testsite99.testing2.com-8443 } "/bob0" { pool bob.testsite99.testing2.com-8443 } "/bobdemo" { SSL::disable serverside pool bob.testsite99.testing2.com-80 }
}

0
Rate this Question
Comments on this Question
Comment made 25-Sep-2014 by Joe_5599 145
Still not liking the additional bracket 01070151:3: Rule [/Common/Waterloo-Test-Combo] error: line 1: [parse error: missing close-brace] [{ #check for URL and send to pool switch [string tolower [HTTP::host]] { sam.testsite99.testing2.com" { pool sam.testsite99.testing2.com-80 } "bob.testsite99.testing2.com" { pool bob.testsite99.testing2.com-80
0
Comment made 25-Sep-2014 by mikeshimkus
I second what THi said, the iRule editor or a Notepad ++ with TCL language selected will show you unbalanced brackets/braces: https://devcentral.f5.com/d/tag/irules%20editor
0
Comment made 25-Sep-2014 by THi 1154
You are missing one closing curly bracket on the second pool. I added it and it passed ok on my BIG-IP
0
Comment made 25-Sep-2014 by Joe_5599 145
Now getting this error. Do I need the 2nd WHEN HTTP_REQUEST statement or do I need an ELSE in between sections? 01070151:3: Rule [/Common/Waterloo-Test-Combo] error: line 10: [Duplicate event/priority] [when HTTP_REQUEST { # check uri and send to pool switch -glob [HTTP::uri] { "/sam1*" { SSL::disable serverside pool sam.testsite99.testing2.com-8080 }
0
Comment made 25-Sep-2014 by THi 1154
I think you can have same event in a single iRule only once. So either combine the logic into one when HTTP_REQUEST -event, or create a second separate iRule and attach that to the same virtual server (evaluation order matters and hope the logics are not conflicting). See https://devcentral.f5.com/articles/stacking-irules-a-modular-approach
0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi, I think you are missing a close bracket in your switch statement.

switch [string tolower [HTTP::host] {

should be:

switch [string tolower [HTTP::host]] {

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Are you missing one closing square bracket in: [string tolower [HTTP::host] { ...?

You can use iRule editor to find syntax errors easier.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

You have a problem as an iRule can't have two times the same event.
Also you had problems on missing square brackets.
This part should work now.

when HTTP_REQUEST { 
    #check for URL and send to pool 
    switch [string tolower [HTTP::host]] { 
        "sam.testsite99.testing2.com" { 
            pool sam.testsite99.testing2.com-80 
        }
        "bob.testsite99.testing2.com" { 
            pool bob.testsite99.testing2.com-80
        }
     } 
}
0