Forum Discussion

david_ed_165839's avatar
david_ed_165839
Icon for Nimbostratus rankNimbostratus
Feb 28, 2016

iRule settings to simulate a virtual server setup

Hi all;

We've been moving our applications from our datacenter to the Azure cloud. I've deployed the F5 in Azure, but due to the one interface allowed I can only have one virtual server per protocol. Due to this I have to either deploy a Local Traffic Policy, or an iRule to create the customized settings for the virtual server. The first application is an Oracle application, and so I have to do two things, insert the WL-Proxy-SSL and then redirect to a pool, based on the URI received. The initial iRule I tried is:

when HTTP_REQUEST {

if { [string tolower [HTTP::host]] eq "cloudstuff.anywhere.com/p6" } {
    HTTP::header insert WL-Proxy-SSL true
            pool pool_cloudstuff.anywhere.com_7123
    }
elseif { [string tolower [HTTP::host]] eq "cloudsstuff.anywhere.com" && "/" } {
    HTTP::redirect "https://cloudstuff.anywhere.com/p6"
    }
}

This doesn't work, the page cannot be found. Through some experimentation this does work:

when HTTP_REQUEST {

HTTP::header insert WL-Proxy-SSL true

if { [string tolower [HTTP::host]] eq "cloudstuff.anywhere.com/p6" } {
            pool pool_cloudstuff.anywhere.com_7123
    }
    pool pool_cloudstuff.anywhere.com_7123
}

Even when I just use the first part and ignore the redirect it still doesn't work. This is the first time I've had to create an iRule, what I ame missing?

1 Reply

  • Hi,

    the uri is not contained in the host header and has a separate irule command to extract the value, this irule below should work although traffic policies may be the recommended approach for what you need to do...

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] eq "cloudstuff.anywhere.com" } {
            switch [string tolower [HTTP::uri]] {
                "/p6" {
                    HTTP::header insert WL-Proxy-SSL true
                    pool pool_cloudstuff.anywhere.com_7123
                }
                "/" {
                    HTTP::redirect "https://cloudstuff.anywhere.com/p6"
                }
            }
        }
    }