Forum Discussion

tabkad_89844's avatar
tabkad_89844
Icon for Nimbostratus rankNimbostratus
Aug 21, 2011

irule for port redirection based on Domain names

 

I have a webserver listening on multiple ports for different urls.

 

 

I have made an irule to start with;

 

I have a webserver listening on multiple ports for different urls.

 

 

I have made an irule to start with;

 

when HTTP_REQUEST {

 

if {([HTTP::host] eq "abc.com") } {

 

pool pool_abc

 

} elseif {([HTTP::host] eq "xyz.com") } {

 

pool pool_xyz

 

} elseif { ([HTTP::host] contains "*.abc.com") } {

 

pool pool_allstar_abc

 

} elseif {([HTTP::host] contains "*.xyz.com") } {

 

pool pool_allstar_xyz

 

}

 

}

 

 

 

My problem is that the wildcard does not work if there is a request coming from *.abc.com. Each pool is representing different ports in my configuration. Any experts inputs will be highly appreciated.

 

3 Replies

  • Hi tabkad,

    Try the following

    
    when HTTP_REQUEST {         
                   switch -glob [string tolower [HTTP::host]] {               "abc.com" { pool pool_abc}
                   "xyz.com" { pool pool_xyz }
                   "*.abc" { pool pool_allstar_abc }
                   "*.xyz.com" { pool pool_allstar_xyz }
             }
    }
    I hope this helps

    Bhattman
  • Hi Bhattman,

     

     

    I tried the following and it just works. But now I faced another hurdle ,

     

     

    Let me just brief the Application behavior ;

     

     

    First the user will hit the pool_abc and then for authentication it has to go to pool_allstar_abc. After getting authenticated the server does a url redirection which it has to go back again on pool_abc.

     

     

    But for me it does not work with this irule as the traffic comes back as http://*.abc.com:3000 and for this reason the user on the internet does not get any response from the Server.

     

     

    Please advise.