Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

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!

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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      

    }
0
Comments on this Answer
Comment made 09-Oct-2017 by sysadmin_2015 256

Hello,

Thank you for the reply, I'll try it. How can I add the host as well as keep the URL string intact?

0
Comment made 21-Oct-2017 by Faruk AYDIN 948

Hope it helps

Please mark it as answer if it works

Regards

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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

0
Comments on this Answer
Comment made 10-Oct-2017 by sysadmin_2015 256

Sorry the "HTTP::host" does not seem to work for any of the above examples. I see traffic hit the pool but the url stays "https://10.1.1.1/qa/test1"; for example. It doesn't switch to https://test.domain.com/qa/test1"; so I get a 404 server error, site not found.

Thank you,

0