Forum Discussion

Indrajit_Basak_'s avatar
Indrajit_Basak_
Icon for Nimbostratus rankNimbostratus
Feb 04, 2014

Need help of I-rule rewrite

Need Help on HTTP rewrite i-rule

Actual server is listening on port 7778 .I created pool of two real servers listening on port 7778

But when the user type http://lmjedwmsaphchh.jeddah.cpksa.local url should get rewrite to http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh but the user should only see http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh

I tried by

when HTTP_REQUEST { if {[string tolower [HTTP::host]] starts_with "lmjedwmsaphchh.jeddah.cpksa.local"}{ HTTP::header replace Host "lmjedwmsaphchh.jeddah.cpksa.local:7778" } } when HTTP_RESPONSE {

if {[HTTP::is_redirect]}{

[string map {lmjedwmsaphchh.jeddah.cpksa.local:7778 lmjedwmsaphchh.jeddah.cpksa.local} [HTTP::header value Location]]

HTTP::header value Location [string map {lmjedwmsaphchh.jeddah.cpksa.local:7778 lmjedwmsaphchh.jeddah.cpksa.local} [HTTP::header value Location]]

}

}
but its not working 

            Regds...Indrajit 

14 Replies

  • Actual server is listening on port 7778 .I created pool of two real servers listening on port 7778

     

    But when the user type http://lmjedwmsaphchh.jeddah.cpksa.local url should get rewrite to http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh but the user should only see http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh

     

    have you tried without irule?

     

  • Yes without I-rule it is working perfect .

     

    Means if user browse http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh page is opening perfectly.

     

    But our requirement is user should only type http://lmjedwmsaphchh.jeddah.cpksa.local same page should open .

     

    Regds..Indrajit

     

  • sorry to not explain well.

     

    you have virtual server listening on port 80 (without irule) and lmjedwmsaphchh.jeddah.cpksa.local is resolved to virtual server ip, isn't it?

     

    if yes, does browsing http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh work?

     

    • Indrajit_Basak_'s avatar
      Indrajit_Basak_
      Icon for Nimbostratus rankNimbostratus
      Hi Nitas , you are right . lmjedwmsaphchh.jeddah.cpksa.local is resolved to virtual IP and if user browses http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh it works . But our requirement is User should only browse http://lmjedwmsaphchh.jeddah.cpksa.local and through i-rule it should be redirected to http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh Regds..Indrajit
    • nitass_89166's avatar
      nitass_89166
      Icon for Noctilucent rankNoctilucent
      does browsing http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh (no :7778, no irule) work?
  • sorry to not explain well.

     

    you have virtual server listening on port 80 (without irule) and lmjedwmsaphchh.jeddah.cpksa.local is resolved to virtual server ip, isn't it?

     

    if yes, does browsing http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh work?

     

    • Indrajit_Basak_'s avatar
      Indrajit_Basak_
      Icon for Nimbostratus rankNimbostratus
      Hi Nitas , you are right . lmjedwmsaphchh.jeddah.cpksa.local is resolved to virtual IP and if user browses http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh it works . But our requirement is User should only browse http://lmjedwmsaphchh.jeddah.cpksa.local and through i-rule it should be redirected to http://lmjedwmsaphchh.jeddah.cpksa.local:7778/forms/frmservlet?config=wmshcrdc-hh Regds..Indrajit
    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      does browsing http://lmjedwmsaphchh.jeddah.cpksa.local/forms/frmservlet?config=wmshcrdc-hh (no :7778, no irule) work?
  • At a minimum there's an iRule syntax issue:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] starts_with "lmjedwmsaphchh.jeddah.cpksa.local" } { 
            HTTP::header replace Host "lmjedwmsaphchh.jeddah.cpksa.local:7778" 
        } 
    } 
    when HTTP_RESPONSE {
        if { [HTTP::is_redirect] } {
            HTTP::header replace Location [string map {"lmjedwmsaphchh.jeddah.cpksa.local:7778" "lmjedwmsaphchh.jeddah.cpksa.local"} [HTTP::header Location]]
        }
    }
    

    This will account for the incoming Host header and any outgoing redirect Location headers. If it still doesn't work, I'd do a capture of the traffic on the client side to see if other :7778 references are getting through to the client (ie. document object references).

  • Concur with Nitass. You need to look at the HTTP responses from the server to see if elements within the response contain the offending URL pattern. Changing the Location header may not be enough if elements within the payload also have the "real" path (image links, CSS, JavaScript, etc.).