Forum Discussion
DannyF_69324
Aug 18, 2011Nimbostratus
iRule to display remote content through fake URI
Hey Guys,
I know there is an iRule like this already out there, but I can't seem to find it. Anyway hopefully one of you guys can help me out.
I'm going to be creating several reseller sites for a company each for which will display their own content. All of these sites will then use only one help site which we created so all the resellers can link to. The problem is that if we create the link to our help they will leave the site and will then be redirected to the help site. We want to prevent this by using an iRule that could display the remote site's content when any specific URI is given.
For example:
The help domain would be https://helpsite.com/help/
The resellers domains would be:
http://reseller1.com
http://reseller2.com
http://reseller3.com
If any of the reseller sites call for http://reseller1.com/help/ we want the help site's content (https://helpsite.com/help/) to be display under the /help/ URI of any reseller site.
I remember seen something like this before but I can't remember the name of this iRule or what functions were used to create this.
Thanks for any help you can provide.
--
Danny Fuentes
- Ed_Hammond_2611NimbostratusSo from the outside you want the http://reseller1.com/help to go to the servers actually supporting http://help site.com/help ? That would be a pool selection based on the hostanme and URI path. Use the "pool" command.
- The_BhattmanNimbostratusTo expand on Ed's description
when HTTP_REQUEST { switch -glob [string to lower [HTTP::uri] "/help"- "/help/" { HTTP::header replace Location "https://helpsite.com/help" Pool pool_helpsite snat automap } } }
- DannyF_69324NimbostratusHey Bhattman,
error: line 3: [parse error: extra characters after close-quote] [- "/help/" { HTTP::header replace Location "https://helpsite.com/help" Pool pool_helpsite snat automap } ] line 4: [undefined procedure: /help/] ["/help/" { HTTP::header replace Location "https://helpsite.com/help" Pool pool_helpsite snat automap }] line 10: [command is not valid in the current scope] [}]
- Michael_YatesNimbostratusHi DannyF,
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/help" - "/help/" { HTTP::header replace Location "https://helpsite.com/help" pool pool_helpsite snat automap } } }
- DannyF_69324NimbostratusThanks Michael looks like that took care of the problem I had trying to add the iRule. Now the problem that I'm seeing is that the iRule does not seem to be parsing the host header into the request to the IP. The remote site is running with NameVirtualHost and since no host header appears to be passing to the iRule it defaults to the first available site under that IP. Is there a way to fix that?
- Michael_YatesNimbostratusHi DannyF,
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/help" - "/help/" { HTTP::header replace Location "https://helpsite.com/help" HTTP::header replace "Host" "helpsite.com" pool pool_helpsite snat automap } } }
- hoolioCirrostratusNice one Michael. Note that you can remove the -glob flag if you're not using wildcards in the switch statement to save some CPU cycles.
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