Forum Discussion

Deon's avatar
Deon
Icon for Nimbostratus rankNimbostratus
Jun 16, 2008

BigIP as Proxy for Cross-Domain XMLHttpRequest Calls?

Is it possible to write an iRule that will allow me to rewrite only specific requests and send them along to another server to fulfill a request for data? The essence of what I need to do is in this diagram/page: http://www.yahooapis.com/javascript/howto-proxy.html except I'd like the BigIP to be the proxy instead of the webserver

 

 

My web app is already hosted behind a BigIP. When the uri begins with something like "/ImageMetaData", then I would need to send that get off to a server/pool different from the normal one. At this point, the load balance decision will have already been made. Can't permanently change the pool and/or the node for the user.

 

 

I've got a skeleton iRule that looks at the uri and finds the matching string, modifies the uri accordingly, changes the host in the header, etc. Not sure where to go from here or if what I am attempting here is even possible or recommended on the BigIP.

 

 

Where can I look for examples or a tutorial on how to proceed?

 

 

Thanks

 

-Deon
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Why don't you post what you've got so far, and we'll see if we have any pointers or suggestions?

     

     

    It sounds like what you're looking for is very doable.

     

     

    Colin
  • Deon's avatar
    Deon
    Icon for Nimbostratus rankNimbostratus
    Here is what I have so far. Not much actually. I guess I am not completely sure what all needs to be changed or rewritten to do what I am attempting to do.

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] starts_with "/ImageMetaData/" }{

     

    log local0. "*********** REQUEST ****************"

     

    log local0. "matched string"

     

    log local0. "host= [HTTP::host]"

     

    log local0. "headernames= [HTTP::header names]"

     

    log local0. "uribefore= [HTTP::uri]"

     

    HTTP::uri "substr [HTTP::uri] 14"

     

    log local0. "uriafter= [substr [HTTP::uri] 14]"

     

    HTTP::header replace Host "172.22.92.28:9095"

     

    log local0. "header Host= [HTTP::header Host]"

     

    log local0. "header Cookie= [HTTP::header Cookie]"

     

    pool DEV_Image_Access_Service

     

    node 172.22.92.28 9095

     

    }

     

    }
  • spark_86682's avatar
    spark_86682
    Historic F5 Account
    That looks somewhat reasonable, though I don't know the ins and outs of XMLHttpRequest. Is it not working for you in some way?