Forum Discussion

Aaron_Tebo_7015's avatar
Aaron_Tebo_7015
Icon for Nimbostratus rankNimbostratus
Aug 26, 2009

proxypass irule

Hello,

 

 

I am using the irule for proxypass found on devcentral http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html. This is half working for me but doesn't redirect. Currently when I go to www.abc.com/forum it doesn't give me the 404 error but it doesn't redirect either. No matter what I put in Data Group tab it just doesn't seem to do anything.

 

 

Basically what I want to do with it is redirect to another website but still look like the original one that the user went too. For example if a user goes to www.abc.com/forum I want it to redirect to www.myforumwebsite.com/myforum but still look like www.abc.com/forum. Any steps in the correct direction will be greatly appreciated.

 

 

Thanks,

 

 

Aaron
  • Hi Aaron,

     

     

    The ProxyPass iRule will rewrite the host and/or URIs in requests before they're sent to the pool. The idea is that the client won't see the change as they would with an HTTP redirect.

     

     

    Can you configure the iRule and datagroup according to the instructions in the Codeshare page, enable debug logging on the rule and then post your configuration and logs from /var/log/ltm if it doesn't work?

     

     

    From what you've posted so far, I think a valid datagroup config entry would look like:

     

     

    www.abc.com/forum www.myforumswebsite.com/myforum

     

     

    You'd want to configure the www.myforumswebsite.com server(s) in a pool and add that pool to the virtual server.

     

     

    Aaron
  • Hi Aaron,

     

     

    I didn't have www.myforumswebsite.com a member in the pool. That fixed it. Thanks for the quick response.

     

     

    Aaron
  • Hello,

     

    I am trying to capture the 404 error from the www.myforumswebsite.com/myforum but I always get the remote 404 error page. If I go to www.abc.com/doesnotexist I get the custom 404 error which I have pasted below. If go to www.abc.com/forum/doesnotexist I get the error page from the www.myforumswebsite.com server. I want it to use the custom one I have below. How do I get the irule to capture the other 404?

     

     

     

     

     

    ---- code ----

     

    when RULE_INIT {

     

    set error_404 {

     

     

     

    404 File or Page Not Found

     

     

     

     

     

     

     

     

    [HTTP::status] Error

     

     

     

     

    Page Not Found

     

    The requested URL
    $HTTP_URI
    was not found on this server.

     

     

     

     

     

     

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    set HTTP_URI [HTTP::uri]

     

    }

     

    when HTTP_RESPONSE {

     

    if { [HTTP::status] == 404 } {

     

    HTTP::respond 404 content [subst $::error_404]

     

    }

     

    }

     

    --code ---

     

     

    Thanks,

     

     

    Aaron
  • Hi Aaron,

     

     

    Can you enable debug on the proxy pass iRule and add logging to the 404 response handling iRule to see if the response status check is matching and the HTTP::respond command is being called?

     

     

    Aaron
  • I found the issue. It was working but the 404 error I was getting back was not a standard 404 error but a custom 404 html page. Is it possible to have the Irule search for text on a page that is loading?
  • You would need to collect the response content of every response and then search for the custom 404 text. It would be a resource intensive effort. It would be much more efficient from the LTM perspective to change the server to send a 404 status code on page not found responses.

     

     

    Aaron