Forum Discussion

Kevin_Leclercq_'s avatar
Kevin_Leclercq_
Icon for Nimbostratus rankNimbostratus
Dec 05, 2005

Irule to access individual web servers

We would like to implement the following if it is possible:

 

 

We go to www.website.com [192.168.1.100]

 

 

In BigIp VIP 192.168.1.100 points to pool: webfarm_80

 

Webfarm_80 Contains the following servers:

 

10.10.10.1:80 (webserver1)

 

10.10.10.2:80 (webserver2)

 

10.10.10.3:80 (webserver3)

 

10.10.10.4:80 (webserver4)

 

10.10.10.5:80 (webserver5)

 

 

We would like to create a rule so that if you specify something like: www.website.com/ip=10.10.10.1 it directs you to webserver1 if not specified you go to the pool: Webfarm_80. We would like to make this rule for all the servers in this pool. Please advise if this is possible and what the correct syntax would be. Thanks

 

 

We are currently running version 4.5.3 but are upgrading to 4.5.13 soon.
  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Kevin,

    there are 2 ways how to achieve your desired behavior:

    1) use direct node select expression in the pool,

    2) create additional pools each containing one of your servers and use

    rule to select pool based on matching the ip= pattern in

    the URI,

    Example configuration for solution 1:

    
    pool webservers {
      select node(findstr(http_uri, "ip=", 3, '/') + ":80")
      member 10.10.10.1:80
      member 10.10.10.2:80
      member 10.10.10.3:80
      member 10.10.10.4:80
      member 10.10.10.5:80
    }
    virtual www.website.com:80 {
       use pool webservers
    } 

    The solution assumes that the ip= portion is separated from the

    actual URI by a slash (e.g. /ip=10.10.10.1/index.html). The disadvantage of this (otherwise elegant) solution is that the node select expression is evaluated on every request.

    Example configuration for solution 2:

    
    pool all_webservers {
      member 10.10.10.1:80
      member 10.10.10.2:80
      member 10.10.10.3:80
      member 10.10.10.4:80
      member 10.10.10.5:80
    }
    pool webserver1 {
      member 10.10.10.1:80
    }
    pool webserver2 {
      member 10.10.10.2:80
    }
    pool webserver3 {
      member 10.10.10.3:80
    }
    pool webserver4 {
      member 10.10.10.4:80
    }
    pool webserver5 {
      member 10.10.10.5:80
    }
    rule server_switch {
      if(http_uri starts_with "/ip=") {
         if(http_uri starts_with "/ip=10.10.10.1) {
            use pool webserver1
         } else
         if(http_uri starts_with "/ip=10.10.10.2) {
            use pool webserver2
         } else
         if(http_uri starts_with "/ip=10.10.10.3) {
            use pool webserver2
         } else
         if(http_uri starts_with "/ip=10.10.10.4) {
            use pool webserver2
         } else
         if(http_uri starts_with "/ip=10.10.10.5) {
            use pool webserver2
         } else
           redirect to ""
         }
      } else {
         use pool all_webservers
      }
    }
    virtual www.website.com:80 {
       user rule server_switch
    }

    As you can see this approach has a little bit of scaling issue in case you need to select from large number of servers. On the other hand it has excellent performance because the more complicated logic is not invoked in the prevailing case, i.e. if no /ip= is specified in the URI (I'm assuming that the /ip= construct is for testing purposes, right?).

  • I keep trying to add this expression to the "Node Select Expression" line but I am getting a "Error 331835 -- Rule string to tree failed. - syntax error at '{' line: 1 " every time. What exactly do I put in the Node select expression box? Thanks
  • Thanks - I am testing this on one of our QA BigIps before using it in production, I found a similar devcentral request and eventually put the following in the Node Select Expression Box: node(findstr(http_uri, "ip=", 3, '/') + ":80") This added without the error message. However, when I try to test it out it doesn't seem to be working. To test this I should be using: www.website.com/ip=10.10.10.1 (10.10.10.1 being the Node IP address of one of the pool members.) I set up a static page to verify what server I am hitting but when I put the full url/ip= info in I keep getting a Page Cannot be Found. Where am I going wrong?
  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    Kevin,

     

     

    the server apparently does not have any page matching the URL containing the "ip=" construct. You need to make sure that the server responds to those URLs. BIG-IP sends the URL to the server as received from client. There is no way, how to modify request URLs before sending them to server, in BIG-IP v4.x.
  • I was able to get what you stated above working on the test BigIp, however there is a new wrench in the works. Here is the overview:

     

     

    We go to www.website.com [192.168.1.100]

     

     

    VIP 192.168.1.100 points to pool:

     

    Webfarm_80

     

    10.10.10.1:80 (webserver1)

     

    10.10.10.2:80 (webserver2)

     

    10.10.10.3:80 (webserver3)

     

    10.10.10.4:80 (webserver4)

     

    10.10.10.5:80 (webserver5)

     

     

    These servers then redirect to: website.com [192.168.1.104]

     

    VIP 192.168.1.104 points to pool:

     

    Webfarm_80

     

    10.10.10.1:80 (webserver1)

     

    10.10.10.2:80 (webserver2)

     

    10.10.10.3:80 (webserver3)

     

    10.10.10.4:80 (webserver4)

     

    10.10.10.5:80 (webserver5)

     

     

    The key is we need to not modify the URL at all beyond the first request. If we have a problem with webserver4, they want to be able to specify in some way such as www.website.com/ip=10.10.10.4 and get redirected to 10.10.10.4/

     

     

    Is this feasible? We can use any method available.