Forum Discussion

achapman_198069's avatar
achapman_198069
Icon for Nimbostratus rankNimbostratus
Apr 23, 2015

iRule to redirect a URI to a different node and URI while masking the url to the user

Is it possible to have an iRule that will redirect a url www.xyz.com/a to a different node and path while masking the url to the client?

 

Example User goes to www.xyz.com/abc, but the ltm sends that request to a different node/URI outside of that pool while still maintaining the original URL?

 

So I guess it would need to see the http host which equals xyz.com and http:uri equals abc/ then redirect to a different node 1.1.1.1 and a uri abcabc/, then rewrite the header to maintain the original URL?

 

I have been looking at proxypass, just not sure if that is the correct solution.

 

I just don't know the syntax to put it into place.

 

6 Replies

  • When you say "then rewrite the header to maintain the original URL?" do you want to send the original URL to the destination server? Or are you simply saying that you don't want the client to know you messed with the headers?

     

    If it is the latter, you can just rewrite the HTTP::host and HTTP:uri headers with the new information because the uri is not included in the http response. Something like this:

     

    when HTTP_REQUEST { if { ([HTTP::host] equals "www.xyz.com") && ([HTTP::uri] equals "/a") } { HTTP::host "www.newhost.com" HTTP::uri "/your_new_uri" pool your_pool } }

     

    Hope this helps.

     

    Robert

     

  • As Robert said, all you need to do is to use the HTTP::uri command to change the URI that is being sent to the backend server. ProxyPass does this on a bigger scale but if you are just trying to do a single URI, then a simple iRule like Robert supplied would work fine.

     

    • Robert_Luechte2's avatar
      Robert_Luechte2
      Icon for Cirrus rankCirrus
      The URL on the client's address bar will not change because you are not issuing a redirect to the user. You are rewriting the URL and URI information and then sending it to the server. The URI and host headers are not included in the http response, so the end user will be unaware of the change.
    • Robert_Luechte2's avatar
      Robert_Luechte2
      Icon for Cirrus rankCirrus
      You're welcome. When I saw achapman, I was wondering if it was you. Give me a call sometime and we can catch up.