Forum Discussion

Thomas_Broeste_'s avatar
Thomas_Broeste_
Icon for Nimbostratus rankNimbostratus
Nov 16, 2006

Wildcard

Hi

 

 

I have the following problem

 

 

I've made an Irule looking like this

 

 

when HTTP_REQUEST {

 

if { [HTTP::host] contains "domain.dk" } {

 

HTTP::host

 

pool pool_PresDK

 

log local0. "domain.dk...."

 

}

 

elseif { [HTTP::host] contains "domain.no" } {

 

HTTP::host

 

pool pool_PresNO

 

log local0. "domain.no...."

 

}

 

elseif {[HTTP::host] contains "domain.se"} {

 

HTTP::host

 

pool pool_PresSE

 

log local0. "domain.se...."

 

 

Above is working fine. All domain is pointing at the same IP address. I now have a series of other domains that point to the same IP adress, but needs to go to the same pool. I need some kind of wildcard so that every hostname not matching the above rule will be sent to the same pool. See below

 

}

 

elseif {[HTTP::host] contains "%any domain but not above%"} {

 

HTTP::host

 

pool pool_PresDK

 

log local0. "domain.dk...."

 

 

}

 

}

 

 

Anybode got any idea??

 

 

best regards

 

 

Thomas

1 Reply

  • You can just use 'else' at the bottom to set a default action for any requests that don't match the first conditions:

    
    if { condition1 }{
       do something
    }
    elseif { condition2 }{
       do something else
    }
    elseif { condition3 }{
       do something
    }
    else {
       do a default action
    }

    You could also use switch to do this, but I think the if/elseif/else structure is a little more efficient. You can check the iRules wiki for switch for more info on this.

    Aaron