Forum Discussion

VictorC's avatar
VictorC
Icon for Nimbostratus rankNimbostratus
Mar 15, 2012

Trying to use iRule to switch pools

Hi all,

 

I'm running LTM 10.2.2 and not sure if this is a bug or just a known limitation. I have two virtual servers, each with an iRule to redirect based on the incoming HTTP host request. This is done to save IP addresses. There's a lot more pools, but I have shortened the code to make it look simple here.

 

 

This works:

 

 

virtual myweb_443 {

 

destination 192.168.1.100:https

 

ip protocol tcp

 

rules ext

 

persist cookie

 

profiles {

 

http_ssl {}

 

tcp {}

 

mysslcert.example.com {

 

clientside

 

}

 

}

 

}

 

rule ext {

 

when HTTP_REQUEST {

 

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

 

"alias1.example.com" {

 

pool alias1-external

 

}

 

"alias2.example.com" {

 

pool alias2-external

 

}

 

default {

 

discard

 

}

 

}

 

}

 

}

 

 

However this doesn't:

 

 

virtual myweb_7777 {

 

destination 192.168.1.100:cbt I put 7777 but BIGIP translates it to cbt

 

ip protocol tcp

 

rules int

 

persist cookie

 

profiles {

 

http {}

 

tcp {}

 

}

 

}

 

 

rule int {

 

when HTTP_REQUEST {

 

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

 

"alias1.example.com" {

 

pool alias1-internal

 

}

 

"alias2.example.com" {

 

pool alias2-internal

 

}

 

default {

 

discard

 

}

 

}

 

}

 

}

 

 

I have to add :7777 to the iRule specifically to make this work but I don't understand why I need to. I didn't think the port is included in the HTTP::host value.

 

 

rule int {

 

when HTTP_REQUEST {

 

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

 

"alias1.example.com:7777" {

 

pool alias1-internal

 

}

 

"alias2.example.com:7777" {

 

pool alias2-internal

 

}

 

default {

 

discard

 

}

 

}

 

}

 

}

 

 

Can someone confirm? Thanks.

 

  • I didn't think the port is included in the HTTP::host value.i do not think so.

     

     

    Hypertext Transfer Protocol -- HTTP/1.1

     

    http://www.ietf.org/rfc/rfc2616.txt
  • Hi Victor,

     

     

    The way that you have configured your Virtual Server you have set the active Port to 7777. The LTM's Virtual Server settings act similarly to a Firewall. If you set that Virtual Server to respond on port 7777 then you will need to access it specifying the port.

     

     

    HTTP is automatically Port 80

     

    HTTPS is automatically Port 443

     

     

    Any other port assignment requires that it be specified or the defaults will be used.

     

     

    80 TCP RFC1945 HTTP/1.0 (May 1996)

     

    80 TCP RFC2068 HTTP/1.1 (January 1997)

     

    80 TCP RFC2616 HTTP/1.1 (June 1999)

     

    80 TCP RFC2965 HTTP State Management Mechanism (October 2000)

     

     

    443 TCP RFC2246 The TLS Protocol Version 1.0 (January 1999)

     

    443 TCP RFC2817 HTTP Upgrade to TLS (May 2000)

     

     

    Additionally if you want your LTM Configuration to use the actual port number that is an available option.

     

     

    You can login to your LTM and execute: bigpipe cli service number and then bigpipe save

     

     

    Then your bigip.conf will list the actual service numbers.

     

     

    Hope this helps.
  • Thanks for the bigpipe cli command tip.

     

     

    We are specifying http and the :7777 in the browser URL. The problem is that the iRule doesn't process it unless I put :7777 in the iRule itself. So you're saying because 7777 is not a standard http port, that is why it needs to be specified in the iRule? Just need to know if that is the requirement. Thanks!
  • Hi Victor,

     

     

    Yes. You will need to specify the Port Number in order for the comparison to work properly.

     

     

    Hope this helps.