Forum Discussion

AlbertoCarlone_'s avatar
AlbertoCarlone_
Icon for Nimbostratus rankNimbostratus
Jul 06, 2017
Solved

iRule redirect to another vip with same IP but diffrent port

Hi all, i need to set an iRule to a VS because we want to balance incoming traffic to a specific pool, but if the request have "/XXX" in the string, the connection has to be redirected to another VS with another application port;

 

Here's what i mean:

 

when HTTP_REQUEST { if {[HTTP::uri] equals "/XXX"} {HTTP::redirect "-IDK-"} else { use pool pool_SERVICE_PORT } }

 

where "-IDK-" is for "I does not know what's proper"

 

gimme an hand, pliiiiiiiiiis!

 

  • Hi Alberto

    when HTTP_REQUEST{
        switch [HTTP::uri] {
            "/xxxx"{
              HTTP::Redirect "http:///"
              }
              default {pool pool_SERVICE_PORT }
        }
    }
    

    HTH Eben.

5 Replies

  • Hi Alberto

    when HTTP_REQUEST{
        switch [HTTP::uri] {
            "/xxxx"{
              HTTP::Redirect "http:///"
              }
              default {pool pool_SERVICE_PORT }
        }
    }
    

    HTH Eben.

    • AlbertoCarlone_'s avatar
      AlbertoCarlone_
      Icon for Nimbostratus rankNimbostratus

      yep, thanks.

       

      i was aiming on something different, sadly. ex:

       

      when HTTP_REQUEST {

       

      if {[HTTP::uri] equals "/XXX"} {HTTP::redirect ";}

       

      else { use pool pool_SERVICE_PORT } }

       

      in order to preserve the "standard" structure of the environment.

       

      Thanks a lot.

       

  • eben's avatar
    eben
    Icon for Nimbostratus rankNimbostratus

    Hi Alberto

    when HTTP_REQUEST{
        switch [HTTP::uri] {
            "/xxxx"{
              HTTP::Redirect "http:///"
              }
              default {pool pool_SERVICE_PORT }
        }
    }
    

    HTH Eben.

    • AlbertoCarlone_'s avatar
      AlbertoCarlone_
      Icon for Nimbostratus rankNimbostratus

      yep, thanks.

       

      i was aiming on something different, sadly. ex:

       

      when HTTP_REQUEST {

       

      if {[HTTP::uri] equals "/XXX"} {HTTP::redirect ";}

       

      else { use pool pool_SERVICE_PORT } }

       

      in order to preserve the "standard" structure of the environment.

       

      Thanks a lot.

       

  • "use" is defunct, upgrade your systems if you require that within iRules. If you're current, you can simply drop the "use" from "use pool" to be just "pool ..."

    You can also skip the redirect and use the "virtual" command.

    when HTTP_REQUEST {
        if { [HTTP::uri] equals "/XXX" }
        {
            virtual /Common/xxx_vs
        }
        else
        {
            pool pool_SERVICE_PORT
        }
    }