Forum Discussion

trx's avatar
Nov 10, 2009

HTTP_Response is NOT responding

Hello All,

 

I have a set of code that does a 301 redirect and when responding, send back a URL to the client browser, but

 

doesn't. The log shows, but the respone URL does NOT get back to the client brower.

 

 

Request Method

 

when HTTP_REQUEST {

 

Special ondemand redirects

 

if { ([HTTP::uri] starts_with "/") } {

 

HTTP::respond 301 Location "http://xyz.com/"

 

log local0. "------301 redirect to xyz.-----"

 

return

 

}

 

}

 

 

when HTTP_RESPONSE {

 

HTTP::header replace Location "http://xxx.com/"

 

log local0. "respond to client xxx"

 

return

 

}

 

 

Can anyone help?

 

 

Thank you.

 

 

Regards,

 

TRX
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi TRX,

     

     

    HTTP_RESPOND is not triggered for LTM generated responses (like when using HTTP::respond or HTTP::redirect). Also, every URI will start with / so you could either make the URI check more specific or remove it altogether if you want to redirect every request. And 'return' exits the current event in the current rule. If you don't have any more code in the event you don't need to use return.

     

     

    Aaron
  • Hello Aaron,

     

    So questions:

     

     

    1) So how would I mask the URL that gets returned to the client browser?

     

    2) How do I trigger the HTTP::RESPONSE?

     

     

    Any help is fully appreciated.

     

     

    Thanks.

     

     

    Regards,

     

    TRX
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Can you explain a bit more on what you're trying to do and why? I'm not sure what you mean by masking a URL.

     

     

    HTTP_RESPONSE is triggered when LTM parses the HTTP headers in a response from a pool member.

     

     

    Aaron
  • Hello Aaron,

     

    I"m still kind of new to IRules. Here's is what I want to happen:

     

    1) User types in "http://xyz.com/

     

    2) Back end redirects to "http://anothersite.com/

     

    3) Respond/leave the current URL in the client browser "http://xyz.com/

     

     

    Does that help?

     

     

    What syntax do I use to trigger the response function?

     

     

    Thanks.

     

     

    Regards,

     

    TRX
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi TRX,

     

     

    That makes more sense. You can use Kirk's ProxyPass iRule from the codeshare to proxy client requests to another web application. It rewrites the host and/or URIs in request headers and payloads and sends the request to a pool. On responses, instances of the host and URI are again replaced with what the client requested so the client doesn't see the internal aliases.

     

     

    If you're running v9, you should use this version:

     

     

    ProxyPass (Click here) - iRule to replace the functionality of Apache Webserver ProxyPass and ProxyPassReverse functions

     

     

    If you're running v10, you should use this version:

     

     

    ProxyPass (Click here) - iRule (for TMOS v10) to replace the functionality of Apache Webserver ProxyPass and ""ProxyPassReverse" functions, allowing for a different server and client view of your web site.

     

     

    It's a bit of a read, but the instructions are fairly complete on how to use it. If you try something and it's not working, try enabling debug in RULE_INIT and post the symptoms of the issue and log output from /var/log/ltm.

     

     

    Aaron