Forum Discussion

ben_svobodny_18's avatar
ben_svobodny_18
Icon for Nimbostratus rankNimbostratus
Mar 18, 2015

change in behavior from v10 to v11 with HTTP:HOST

I have ran into an issue with an irule that is working fine on version 10, but doesn't work on version 11.

 

In version 10 we can rewrite the HOST value, but still make parsing decisions off of the original host value that is requested.

 

But in version 11 it appears that once you change the host value you can no longer make parsing decisions off of the original host value.

 

Can anyone help me gain back this functionality?

 

set apiHostProd "test.com" set apiPoolProd "test.com-81"

 

if { [class match $cmd equals "api_commands"] } { HTTP::header replace "Host" $apiHostProd

 

if { [HTTP::host] contains"resell01" } { pool $apiPoolProd member 10.7.58.28 81 } elseif { [HTTP::host] contains"resell02" } { pool $apiPoolProd member 10.7.58.29 81 else { if { [HTTP::host] equals "test.com"} {pool $apiPoolProd } else { return error } }

 

LOGS SHOWING THE HOST VALUE

 

ver 11 Mar 18 07:39:06 slot2/host info tmm1[10895]: Rule /Common/test-apidotnetpci-80-v4 : http host is test.com

 

ver 10 Mar 18 07:58:13 local/tmm info tmm[5191]: Rule test-apidotnetpci-80-v3 : http host is resell01

 

2 Replies

  • You could grab the original host value into a variable and base it on that. Otherwise, I'm not sure of a way to get the original once you modify it.

    You could update your iRule to something like this:

    set origHost [HTTP::host]
    set apiHostProd "test.com" 
    set apiPoolProd "test.com-81"
    
    if { [class match $cmd equals "api_commands"] } { 
        HTTP::host $apiHostProd
        HTTP::header replace "Host" $apiHostProd
    }
    
    switch -glob -- [string tolower $origHost] {
        "*resell01*" { 
            pool $apiPoolProd member 10.7.58.28 81 
        }
        "*resell02*" { 
            pool $apiPoolProd member 10.7.58.29 81
        }
        "test.com" {
            pool $apiPoolProd 
        } 
        default {
            HTTP::respond 200 content { Error Message To Return To User }
            return
        }
    }