Forum Discussion

Reginald_Sible1's avatar
Reginald_Sible1
Icon for Nimbostratus rankNimbostratus
Oct 02, 2013

How do you build an iRule to re-direct a VIP to a server based on URL?

Im trying to create a vip with the address of 205.157.112.167 port 80 and I want traffic with the url of "/NorwoodWSConfigBridge/NorwoodWSConfigBridgeuri" to go to node 205.157.77.42 port 7002 and url "/PSIGW/PeopleSoftService" to go to node 205.157.77.43 port 7000

 

Can Anyone here help?

 

4 Replies

  • This is pretty straightforward. You can do something like:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/norwoodwsconfigbridge/norwoodwsconfigbridgeuri" } {
            HTTP::respond 301 Location "https://205.157.77.42:7002"
        } elseif  { [string tolower [HTTP::uri]] starts_with "/psigw/peoplesoftservice" } {
            HTTP::respond 301 Location "https://205.157.77.43:7000"
        }
    }
    

    FYI, this isn't tested, please run your checks before implementing in a production mode.

  • Try this:

    when HTTP_REQUEST {    
        switch -glob [string tolower [HTTP::uri]] {
            "/norwoodwsconfigbridge/norwoodwsconfigbridgeuri*" {            
                node 205.157.77.42 7002
            }            
            "/psigw/peoplesoftservice*" {            
                node 205.157.77.43 7000
            }
            default {
                pool local-pool
            }
        }
    }
    

    where "local-pool" is a pool to send traffic to if the request URI doesn't match either of the previous conditions.

  • I just noticed that you said node for the redirect. Using samples from: iRules 101 - 05 - Selecting Pools, Pool Members, and Nodes

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/norwoodwsconfigbridge/norwoodwsconfigbridgeuri" } {
            pool MYPOOL member 205.157.77.42 7002
        } elseif  { [string tolower [HTTP::uri]] starts_with "/psigw/peoplesoftservice" } {
            pool OTHERPOOL member 205.157.77.43 7000
        }
    }
    

    (edited for case issues)

  • What is the difference between the to I rules you guys posted?

     

    The node command sends to a specific node, regardless of pool membership, while the pool command, specifically pool [pool name] member [IP] [port] sends traffic to a specific pool member, which must exist in the pool. In my opinion, using the node command is really no better or worse than using the pool member command. They're both targeting a specific service regardless of any load balancing or health status. You didn't mention a pool configuration, so I went with the node option.