Forum Discussion

Maynor_Ovalle's avatar
Maynor_Ovalle
Icon for Nimbostratus rankNimbostratus
May 02, 2007

How do I rewrite a private dns redirect to a public available dns since the app is being accessed externally

I'm very new at writting iRules but would love some assistance or tips on how we can accomplish the following.

 

 

We basically have a web application that is making internal url redirects on a public assessible web site. What we need to do is to be able to catch that redirect on an HTTP_RESPONSE and rewrite it with the public accessible url but still keep the HTTP::uri header untouched. There seems to be some limitation where you can not use HTTP::uri header call on an HTTP_RESPONSE. Any ideas on how we can accomplish this? Thanks for your assistance. Below is an example of what we thought would work.

 

 

when HTTP_RESPONSE {

 

if { [HTTP::host] contains "internalurl.com"} {

 

HTTP::redirect "publiurl.com" ":" 1][HTTP::uri]

 

}

 

}

3 Replies

  • This ProxyPass iRule is made to handle this kind of thing:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Not to negate Kirk's suggestion, but I'm always a fan of the simplest solution possible, so I'll just point out that many customers facing this dilemma can probably get away with using a couple of built-in features instead of an iRule.

    If all you need to do is rewrite the redirect sent by your pool members to reference the virtual server hostname instead of their own, set "Redirect Rewrite" to "All" in the HTTP profile (or "Matching" if some redirects will be to other hostnames).

    If you also need to re-write any self-referencing outbound links imbedded by pool members in the response pages to reference the virtual server hostname instead, create and apply a stream profile with the following values:
    source: 
    target: @node1.domain.com@vs.domain.com@ @node2.domain.com@vs.domain.com@ @node3.domain.com@vs.domain.com@@
    which will perform a single pass replacement looking for the first value in each pair, replacing with the 2nd.

    If you need more than that, an iRule would most likely be the best solution.

    /deb
  • I will be trying out the easy solution first. Thanks for your imput I'll post the solution just as reference.