Forum Discussion
Steve_87232
Nimbostratus
Aug 30, 2010ProxyPass - Reverse Proxy / Backend URL rewrite.
I have been trying to allow a user to type (for example) www.google.com in their browser, that then is sent to a virtual server on the LTM that sends the request to www.yahoo.com. The user sees the content of www.yahoo.com but their browser still shows www.google.com. So far I have had no luck in getting this going. I have looked at a number of iRules and not found one that meets my needs. ProxyPass seems to be the closest but I can not get it to work. I am a network guy and not a programmer so maybe I just don't get the iRule logic. Can anyone help me? The LTM needs to send traffic to that URL and resolve it via DNS as the site could change.
note, the URL is really more like what the user types: service.mycompany.com and it needs to redirect to externalsite.longurl.application.service.othercompany.com. Will need the LTM to change it on the way back too.
21 Replies
- George_Watkins_Historic F5 AccountSounds like you're rewriting the URI, but you want an HTTP redirect. You just need to create an iRule and assign it to the virtual in questions. Something like this:
when HTTP_REQUEST { if {[string tolower [HTTP::host]] starts_with "service.mycompany.com" } { HTTP::redirect http://externalsite.longurl.application.service.othercompany.com[HTTP::uri] } }
-George - Chris_Miller
Altostratus
Posted By watkins on 08/30/2010 04:04 PM Sounds like you're rewriting the URI, but you want an HTTP redirect. You just need to create an iRule and assign it to the virtual in questions. Something like this:when HTTP_REQUEST { if {[string tolower [HTTP::host]] starts_with "service.mycompany.com" } { HTTP::redirect http://externalsite.longurl.application.service.othercompany.com[HTTP::uri] } }
-George And this is where I got confused...he mentioned a user being able to see www.yahoo.com in their browser while their traffic was sent to www.google.com It's like a host-header re-write for outbound traffic üòõ - Steve_87232
Nimbostratus
Thanks George but this really does not accomplish what I am being asked to do. This does a successful redirect but shows to the user as a redirect. I need that to be hidden. That is the first step. Once I get that working I need the F5 to change all links presented on the page to the customer URL from provider URL. We basically need an external site from a 3rd party provider to appear as an internal web site. - Chris_Miller
Altostratus
Steve...it's easy enough to rewrite the host or URI between LTM and the server...but are you basically trying to do that for outbound traffic?
Perhaps if you could outline the traffic flow you desire, it might be easier. - Steve_87232
Nimbostratus
Chris, What I am waiting to do is have users go to www.internal-url.com and get content from www.external-url.com. The traffic flow is Client types internal-url --> LTM --> external-url. Return traffic: external-url --> LTM --> client (and appears as intenral-url) I recognize this is an odd request and I may be getting terms wrong so I apologies for that. - Chris_Miller
Altostratus
Thanks for clearing that up Steve.
Why not simply do a DNS CNAME for this?
In order to get your traffic externally, you're going to need DNS's help, so merely changing the host header isn't necessarily going to help us here. Simply doing a DNS CNAME might though.
So, you'd simply need to create an Alias/CNAME for "www" in the internal-url.com DNS zone that pointed to "www.external-url.com"
This make sense? - The_Bhattman
Nimbostratus
Hi Steve,
What are you asking won't be accomplished without the iRules so I want to apologize upfront but I am going to start throwing you up some iRule code. It sounds like you don't want re-write but you basically want a webproxy
Here is a piece of untested code
However, there are some items you will need to address before hand.
- The ADC must have access to internet
- You must make sure that you have configured the ADC for DNS local lookup as described in SOL5299 located in ask.f5.com (Don't ask me how I remember this stuff 🙂 )
Obviously this is a simple example but my hope at the very least is that it generates ideas in this discussion.when HTTP_REQUESTED { if { [HTTP::host] eq "www.yahoo" } { NAME::lookup www.google.com Wait until name resolution is completed before sending you to the new page HTTP::collect } } when NAME_RESOLVED { set response [NAME::response] resolved www.google.com to an ip address via load balancer and now use that in the node command. switch [llength $response] { 0 { HTTP::respond 500 content "Couldn't Process Request} default { HTTP::uri "[HTTP::uri]" HTTP::header replace "Host" "www.google.com" node [llindex $response 0] 80 } } HTTP::release }
I hope this helps
Bhattman - Steve_87232
Nimbostratus
I did ask first why we could not use DNS as you mention but was told the reason is the web page services up links that are hard coded to the external URL. Plus it also sends back a cookie with the external URL. It all needs to be modified before returning it to the client, that is where the LTM comes in. - The_Bhattman
Nimbostratus
Sounds like you simply need to point to the website and do some URL rewriting. Cookie can also be adjusted as well
Are the links different or the same?
Bhattman - JRahm
Admin
The functionality you are looking for is in the well documented proxypass iRule.
http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPass.html Click Here
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
