Forum Discussion

XINGYU_99486's avatar
XINGYU_99486
Icon for Nimbostratus rankNimbostratus
Nov 26, 2014

Troubleshoot iRule for HTTP header rewrite

I am not a iRule expert 🙂

What the client wants is that, if the client browse https://cv89ppen.hrms.com, it will be forwarded to cv99pp.hrms.com/psp/CV89PP/?&cmd=login&languageCd=ENG.

or if the client browse https://cv89ppfr.hrms.com, it will be forwarded to cv99pp.hrms.com/psp/CV89PP/?&cmd=login&languageCd=CFR.

or if the client browse cv89pp.hrms.com, it will simply append "/CV89PP/signon.html".

The virtual server does the SSL offloading.

For any reason, only the append part worked. Nothing happened when client browse https://cv89ppen.hrms.com/ and https://cv89ppfr.hrms.com, and it even won't leave the logging information.

Can anybody take a look? Below is my iRule.

Thanks.

====================================================================================

when HTTP_REQUEST {

log local0. "Client [IP::client_addr] is accessing [HTTP::host][HTTP::uri]"

if {[HTTP::uri] equals "/"} {

   switch -glob {string tolower [HTTP::host]} {

   "cv89ppen.hrms.com" {

                       HTTP::header replace Host "cv99pp.hrms.com"

                       HTTP::uri "/psp/CV89PP/?&cmd=login&languageCd=ENG"

                       log local0. "Client [IP::client_addr] is redirected to [HTTP::host][HTTP::uri]"

         }
   "cv89ppfr.hrms.com" {
                       HTTP::header replace Host "cv99pp.hrms.com"
                       HTTP::uri "/psp/CV89PP/?&cmd=login&languageCd=CFR"
                       log local0. "Client [IP::client_addr] is redirected to [HTTP::host][HTTP::uri]"
    }

        "cv89pp.hrms.com" {

                       HTTP::uri "/CV89PP/signon.html"

         }

}

}

}

3 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Is the iRule assigned to both VIPs (port 80 and 443)?

     

  • No it only applied to VIP on HTTPS.

     

    The VIP on HTTP simply redirected to HTTPS.

     

  • can you try to change from {string tolower [HTTP::host]} to [string tolower [HTTP::host]]?