Forum Discussion

Tomasz_93254's avatar
Tomasz_93254
Icon for Nimbostratus rankNimbostratus
Feb 18, 2011

Irule strange problem

I have the following Irule on my LTM F5:

 

 

when HTTP_REQUEST {

 

set subpath [HTTP::uri]

 

if {[HTTP::host] equals "aaa.co.uk"} { HTTP::respond 301 Location "http://www.aaa.co.uk$subpath" }

 

elseif {[HTTP::host] contains "www.aaa.co.uk"} {use pool pl_it_www-aaa-co-uk_p80 }

 

elseif {[HTTP::host] contains "www.aaa.com"} {use pool pl_it_www-aaa-com_p80 }

 

elseif {[HTTP::host] equals "bbb.com"} { HTTP::respond 301 Location "http://www.bbb.com$subpath" }

 

elseif {[HTTP::host] equals "www.bbb.com" and [HTTP::uri] contains "/qqq"} { HTTP::respond 301 Location "http://www.bbb.com" }

 

elseif {[HTTP::host] equals "www.bbb.com" and [HTTP::uri] contains "/default.html"} { HTTP::respond 301 Location "http://www.bbb.com" }

 

elseif {[HTTP::host] contains "www.bbb.com"} {use pool pl_it_www-bbb-com_p80 }

 

}

 

 

The rule works fine but only if there is a default pool associated in virtual server configuration. If I change this Default Pool to None from the drop down, the Irule stops working. Any obvious reasons why it happens?

 

 

BRs

 

 

2 Replies

  • Can you try this? It's explicitly setting the pool or redirect for each case.

    when CLIENT_ACCEPTED {
        Save the VS default pool name
       set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
       switch [string tolower [HTTP::host]] {
          "aaa.co.uk" { HTTP::respond 301 Location "http://www.aaa.co.uk[HTTP::path]" }
          "www.aaa.co.uk" { pool pl_it_www-aaa-co-uk_p80 }
          "www.aaa.com" { pool pl_it_www-aaa-com_p80 }
          "bbb.com" { HTTP::respond 301 Location "http://www.bbb.com[HTTP::path]" }
          "www.bbb.com" {
             switch -glob [HTTP::path] {
                "*/qqq*" { HTTP::respond 301 Location "http://www.bbb.com" }
                "*/default.html" { HTTP::respond 301 Location "http://www.bbb.com" }
                default { pool pl_it_www-bbb-com_p80 }
             }
          }
          default {
             pool $default_pool
          }
       }
    }

    Aaron
  • I have tried this and the script is not working either. NOnetheless I think I found the root of the problem.

     

    When I did debugging:

     

    ------

     

    when HTTP_REQUEST {

     

    log local0. " URI: [HTTP::uri], Host: [HTTP::host] ,Path: [HTTP::path]"

     

    ------

     

    Sample log shows:

     

    URI: http://www.bbb.com/aaaa, Host: ,Path: http://www.bbb.com/aaaa

     

    ---

     

    HTTP::host for some reason is not set, which is most probably the reason none of the if statements were matched.Any idea why HTTP::host is empty? How can I obtain the host which should be www.bbb.com?