Forum Discussion

Remco_257504's avatar
Remco_257504
Icon for Nimbostratus rankNimbostratus
Jan 09, 2018

Set server port trough an irule

For an application we need to an irule that translate url's to different ports

So ex.aplication.eu/first_screen to port 1100 ex.aplication.eu/second_screen to port 1200 ex.aplication.eu/third_screen to port 1300

At the moment we have managed to do this by making separate pools for all ports and set the sessions to a pool with a "when HTTP_REQUEST then set pool" irule. But operations wise this isn't a "nice" solution.

We think it should be possible to alter the destination port through an irule so then we only need one pool. but we can't get is to work...

We have tried:
    when LB_SELECTED {
        if {[class match -value "[HTTP::path]" contains "/first_screen"] }
            { LB::reselect pool [LB::server pool] member [LB::server addr] 1100          
        } 

 and

    when HTTP_REQUEST {
         }
          if { [HTTP::host] contains "ex.aplication.eu" and [HTTP::uri] starts_with "/first_screen" } { 
              set new_port 1100
              return
          }  
    when LB_SELECTED {
    if  { $new_port == 1100 } { 
    log local0. " succes!" 
      node [LB::server addr] 1100
      log local0. "after: [LB::server pool]:  : [LB::server addr]"
    }

But until now, al attemps result in the flowing error: - failed to find pool member (line 1)

1 Reply

  • Hello Remco,

     

    here is a solutions for you: when LB_SELECTED { LB::reselect pool [LB::server pool] member [LB::server addr] 1100 }

     

    You have to use "LB::reselect" function.

     

    Let me now if you need additional information...

     

    Regards,