Forum Discussion
Reverse Proxy Redirect
First off apologies that this has been asked and answered before but I can't seem to get it work correctly, so maybe I am not searching correctly.
So the pretty simple explanation of what we are trying to do is this: On the surface person goes to and without changing the url for SEO reasons we want to load data from locations.domain.com which is just a CNAME for another domain that is going to be called ran by a 3rd party company.
I have tried to write iRules and have had no such luck and have even tried to use the ProxyPass iRule with no luck. I'm not very handy at writing these iRules and having trouble getting what should be something simple to work.
4 Replies
- Robberhines_120
Nimbostratus
Sorry I should have added what I have so far:
when HTTP_REQUEST { if { ([string tolower [HTTP::host]] == "www.domain.com") and (([string tolower [HTTP::uri]] contains "/locations")) } { log local0. "Test Redirect iRule Triggered" HTTP::redirect "locations.domain.com[HTTP::path]" log local0. "[HTTP::host][HTTP::path]" } }So what I have naturally is a redirect that catches /locations but I am unsure the next steps to make the F5 just get the contents of http://locations.domain.com to make it still look like its coming from http://www.domain.com/locations
- Stephane_Viau
Nimbostratus
I think what you want to do is transparently rewriting the URL instead of sending the browser a redirect, no? Is your concern that the client browser sees the change and you want to avoid that behavior?
- Robberhines_120
Nimbostratus
Correct, our clients concern is that they don't, for SEO reasons and such to not have locations.domain.com crawled. They want to make all requests to /locations look like it's coming from even though they are not.
- Stephane_Viau
Nimbostratus
Simple answer is you can change values for the host and the path before the request is passed on to the backend servers. For example :
when HTTP_REQUEST { HTTP::header replace "Host" "locations.domain.com" HTTP::path "/" }This would transparently rewrite whatever you had before to http://locations.domain.com/ .
But, this might cause your application to misbehave. The reason for this is that your app server doesn't know about the rewriting that's happening, and so it will generate HTML code and cookies and such based on what it sees, which is different from what the client sees. So for example, your app server could generate a cookie for locations.domains.com but the client still sees the old name . Therefore the client will not try to re-use the cookie because from its point of view the cookie does not match the site name.
So in this case you will need to use a Rewrite Profile (Profiles --> Services --> Rewrite) to try to rewrite everything that's coming in and back out until your app works correctly. This could be time consuming unfortunately but I don't know of a better way to do it. Look at this piece of documentation here about URI translation :
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
