For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

pvaughan's avatar
pvaughan
Icon for Nimbostratus rankNimbostratus
Nov 20, 2013

Need help with Irule to redirect based on http path or host header

I need to create an irule that will redirect traffic to a different pool bassed on the following criteria. The http path begins with /socket.io OR ((The http header 'Upgrade' contains the string 'WebSocket') AND (the http header 'Host' begins with 'ws')). This is what I have so far, any help is appreciated.

 Assign a pool HTTP path

when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::path]] { 
        "/socket.io*" {
         select the pool 
            pool poolA

    }

elseif HTTP::request {
    switch -glob [string tolower [http_host]] contains { "

19 Replies

  • Just going to the page via internet explorer. When I go to the main page with no uri I get nothing back. So none of the conditions should match and I should be sent to the default pool. Works fine before I put the irule in.

     

  • Is it a SSL traffic ? If yes are you doing SSL termination on your BIG-IP ?

     

    Otherwise, could you add a pool assign condition to your last line in order to check if it matches your iRule.

     

  • It is SSL traffic and it is being terminated on the LTM. I'm not following you on the pool assign condition.

     

  • Sorry, I made a mistake using the word condition.

    What I suggested to you is to add this at the end of your iRule

    Otherwise use default pool
    pool your_poolname
    }
    
  • You can add an else but it's not mandatory because it's your last order in your iRule.

     

  • New irule still doesn't work, same as before. Going to try support. Thanks

    Assign a pool HTTP path matches
     when HTTP_REQUEST {
     if { [string tolower [HTTP::path]] starts_with "/socket.io*" } {
        pool pl_vantage-beta_1337
    Or if header string matches    
    } elseif { { [HTTP::header "Upgrade"] contains "WebSocket" } && { [string tolower  [HTTP::host]] starts_with "ws" }} {
        pool pl_vantage-beta_1337 }
    Otherwise use default pool
        pool pl_vantage-beta_http
        }