Listening on all ports, then select pool based on requested Port

From Tech-Wiki
Jump to: navigation, search

Back to iRules

Remote server port

when CLIENT_ACCEPTED {
 switch [TCP::remote_port] {
   110 { pool POP3 }
   25 { pool SMTP }
   default { discard }
 }
}

Same as below

when CLIENT_ACCEPTED {
 if {[TCP::remote_port] == 110} {
   pool POP3
 } elseif {[TCP::remote_port] == 25} {
   pool SMTP
 } else {
   discard
 }
}

For client port detection use below

when HTTP_REQUEST {
 if { [TCP::local_port] == 8400 } {
   HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
 }
}

Or below

when SERVER_CONNECTED { 
 if {[TCP::remote_port] != 443} { 
   SSL::disable 
 } 
}
when CLIENT_ACCEPTED { 
 if {([TCP::local_port] == 5799 )} { pool pool_5799 } 
 if {([TCP::local_port] == 5800 )} { pool pool_5800 } 
 if {([TCP::local_port] == 10001 )} { pool pool_10001 } 
 else 
  reject 
}

Or below

when CLIENT_ACCEPTED {
 set MYPORT [TCP::local_port]
 switch $MYPORT {
   3389 {
     node 192.168.104.10 3389
   }
   3390 {
     node 192.168.104.11 3389
   }
   3391 {
     node 192.168.104.12 3389
   }
 }
}