Forum Discussion

Neil_Harbaruk_1's avatar
Neil_Harbaruk_1
Icon for Nimbostratus rankNimbostratus
Aug 01, 2006

iRule for https:URL:<port>/URI

I am looking for a script to forward based on any combination of URL:/URI.

 

 

e.g. https://web1.whatever.com:8081/money --> pool1

 

https://web1.whatever.com:8081/coins --> pool1

 

https://web2.whatever.com:8082/coins --> pool2

 

https://web3.whatever.com:8082/coins --> pool3

 

 

If using nested else-if statements, i'd like to use the url's web1, web2, web3 as the main selection criteria. For each group of web1, 2, 3, there will be a whole bunch of web1, 2, 3 statements which will be have either different port numbers or different uri's (or both)

 

 

I have not scripted anything in years, so please bear with me.

 

 

I appreciate any assistance on this.

 

3 Replies

  • Hi,

    Which pool would you want selected for the following requests?

    https://web1.whatever.com:8082/money --> ?

    https://web2.whatever.com:8081/coins --> ?

    Do you want the web1 host to determine the pool, or do you want the port to determine the pool?

    Assuming you only want to look at the host name to make the decision on which pool to use, you could follow the examples in this post: Click here

    
    when HTTP_REQUEST {
       switch [HTTP::host] {
          "web1.whatever.com" {
             log local0. "Detected web1.whatever.com"
             pool pool1
          }
          "web2.whatever.com" {
             log local0. "Detected web2.whatever.com"
             pool pool2
          }
          default {
             log local0. "Using default pool"
             use pool http-pool-myasp
          }
       }
    }

    Else, if you have a lot of hosts/pools, you could use Joe's suggest in the linked post and use a class and findclass to make the load balancing decision.

    Thanks,

    Aaron
  • Depending on which URL and/or which port, and/or which URI, the pool selection would be made. The common thing is the URL. I was looking at nested else-if statements to do this.

     

     

    e.g.

     

     

    if web1

     

    else-if port 1

     

    else-if uri1

     

    use pool x

     

    if web1

     

    else-if port 2

     

    else-if uri1

     

    use pool y

     

    if web1

     

    else-if port 2

     

    else-if uri3

     

    use pool z

     

     

    etc...

     

     

    I know it is going to be rather complicated, not to mention confusing, but I'll have to come up with something no matter how ugly it is because that is the way things are set up now and I cannot change them.

     

     

    Do I use the same statements and syntax whether using http or https? This is all https.

     

     

     

     

     

     

  • The rule would be the same for HTTP or HTTPS, as BIG-IP will need to decrypt the traffic to read the host for the request.

     

     

    If you need to evaluate both the host and the uri, I think the most efficient way to do it would be to use nested switch statements. I'm not sure whether that's possible with TCL though. If it's not, you could use if/else-if's for the host and then nested switches to check the ports.

     

     

    Aaron