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
Sort By
- 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] } }
- 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] } }
- 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? - 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. - The_Bhattman
Nimbostratus
Hi Steve,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 }
- 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 - JRahm
Admin
The functionality you are looking for is in the well documented proxypass iRule.
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