Forum Discussion

SimonaPanzica_2's avatar
SimonaPanzica_2
Icon for Nimbostratus rankNimbostratus
Jun 30, 2015

redirect traffic based on x-forwarded-host

Hi,

 

I have a service that writes x-forwarded-host headers inside the HTTP packets and I need to intercept all the packets coming to the Big-IP with a specific X-Forwarded-Host name and redirect it to a specific pool. How will the iRule look like?

 

Thanks

 

2 Replies

  • a basic iRule to accomplish that might look something like this:

    when HTTP_REQUEST {
        if { [HTTP::header exists "X-Forwarded-Host"] } {
            switch [HTTP::header value "X-Forwarded-Host"] {
                "example.com" {
                    pool abc"
                }
                "example1.com" -
                "example2.com" {
                    pool "xyz"
                }
                default {
                     Do nothing or set default pool
                }
            }
        }
    }