Forum Discussion

sysadmin_2015_2's avatar
sysadmin_2015_2
Icon for Nimbostratus rankNimbostratus
Oct 09, 2017

iRule - Add Host Header

Hello,

Currently we use the below iRule to route traffic from a 3rd party company, its been working great so far. But now we have set up a VPN tunnel with this 3rd party where there traffic is nat'd to the virtual servers ip, they are no longer coming in as test.domain.com/qa>VS IP>iRule routes to the appropriate pool. There coming in as for example as 10.1.1.1/qa>VS IP>iRule routes to the appropriate pool. The iRule is still routing correctly because its picking up the URL but because there not coming in as test.domain.com the host binding is not be picked up by IIS. Is there a way insert the host header and still route accordingly?

when HTTP_REQUEST { if {[HTTP::uri] contains "qa/test1" } { pool Pool_QA_test } elseif {[HTTP::uri] contains "prod/test1" } { pool Pool_Prod_test

    } elseif {[HTTP::uri] contains "qa/test2" } {
           pool Pool_QA_test      

    } elseif {[HTTP::uri] contains "prod/test2" } {
           pool Pool_Prod_test      

    }

}

Thank you for your help!

2 Replies

  • Try this :

    } elseif {[HTTP::uri] contains "qa/test2" } {
               HTTP::host test.domain.com
               pool Pool_QA_test      
    
        } elseif {[HTTP::uri] contains "prod/test2" } {
               HTTP::host prod.domain.com    
               pool Pool_Prod_test      
    
        }
    
  • Here is an optimized version of your Irule.

    when HTTP_REQUEST { 
        switch [HTTP::uri] {
            "qa/test1" -
             "qa/test2"   { 
                HTTP::host test.domain.com
                pool Pool_QA_test
             } 
            "prod/test1" -
            "prod/test2" { 
                HTTP::host prod.domain.com
                pool Pool_Prod_test      
             }
        }
    }    
    

    HTTP::host command only modify host header without change of URI