Forum Discussion

rfelsburg_12081's avatar
rfelsburg_12081
Icon for Nimbostratus rankNimbostratus
Mar 20, 2013

Question regarding port passthrough to pools

Basically, we have a pool setup with each member being

 

 

member1.example.com:0

 

member2.example.com:0

 

with a vip of lb.example.com listening on all ports.

 

 

 

Each pool member recieves the port passed by the client via the URL. I'm looking to change the port that is passed to the pool member though, so that if the user enters: lb.example.com:8080, the port passed to the member pool is 8082 instead of 8080, as if the user had entered lb.example.com:8082.

 

 

I wrote my existing iRule, thinking that the port passed to the pool, was simply the one in the Host header. It's not. Even after modifying the host header, the connection goes onto the original port. Any thoughts? Please let me know if I haven't explained it well enough, I'll snag actual definitions.

 

 

For a little scope, the idea is to abstract the port away from the originating URL, and the pool members completely. So that the iRule alone controls what port is gone to, and instead of having a pool for each port, we have a single pool that picks up the port from the iRule.

 

 

when HTTP_REQUEST {

 

set new_host "[getfield [HTTP::host] : 1]:8082"

 

HTTP::header replace Host "$new_host"

 

}

 

 

 

2 Replies

  • is it something like this? i assume http path is in "/port number/something" form.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       translate service enable
       snat automap
       pool foo
       destination 172.28.19.252:any
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b pool foo list
    pool foo {
       members {
          200.200.200.101:any {}
          200.200.200.111:any {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when CLIENT_ACCEPTED {
       set reselect 0
    }
    when LB_SELECTED {
       if { $reselect } { return }
    
       log local0. "path [HTTP::path]"
       if { [scan [HTTP::path] {/%d/%*s} port] == 1 } {
          log local0. "port $port"
          log local0. "\[LB::server addr\] [LB::server addr]"
          set reselect 1
          LB::reselect
          log local0. "LB::reselect"
          node [LB::server addr] $port
          log local0. "node [LB::server addr] $port"
       }
    }
    when SERVER_CONNECTED {
       log local0. "client [IP::client_addr]:[TCP::client_port] server [IP::remote_addr]:[TCP::remote_port]"
    }
    }
    
    [root@ve10:Active] config  tail -f /var/log/ltm
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : path /8082/something
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : port 8082
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : [LB::server addr] 200.200.200.101
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : LB::reselect
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : node 200.200.200.101 8082
    Mar 21 08:46:07 local/tmm info tmm[4950]: Rule myrule : client 172.28.19.251:36214 server 200.200.200.101:8082
    
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : path /82/something
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : port 82
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : [LB::server addr] 200.200.200.111
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : LB::reselect
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : node 200.200.200.111 82
    Mar 21 08:46:28 local/tmm info tmm[4950]: Rule myrule : client 172.28.19.251:48129 server 200.200.200.111:82
    
    
  • Close, except, instead of the port being in the path, they want to set the port just via the iRule.

     

     

    Either way this worked perfectly, thank you so much.

     

     

    -Rob