Forum Discussion
Christian_Meiss
Aug 05, 2016Nimbostratus
simulate special mod_proxy behaviour
Hi folk,
I can reproduce the following
ProxyPass /foo http://host.domain.tld/foo
with
if {[HTTP::uri] eq "/foo"}{
pool target_pool
}
But i'm not able to do this:
...
Kai_Wilke
Aug 05, 2016MVP
Hi Christian,
to translate the
[HTTP::uri]
while forwarding the request to your internal server, you could use the rather simple iRule below. The [string range]
command will simply strip the first four chars (e.g. /foo
) from the original URI and substitute the internal path (e.g. /bar
) into a new [HTTP::uri]
value.
if { [string tolower [HTTP::uri]] starts_with "/foo" } then {
HTTP::uri "/bar[string range [HTTP::uri] 4 end]"
pool bar_pool
}
But depending on your application requirements, you may also need to translate
[HTTP::header value Referer]
values on each request and untranslate [HTTP::header value Location]
, [HTTP::header value Content-Location]
, [HTTP::cookie domain]
, [HTTP::cookie path]
and even embeded links in [HTTP::payload]
on each response to reflect the external URI namespace.
Note: Personally I always try to avoid hostname and path translation as much as possible. It makes stuff more complex and prone to errors...
I'd like to encourage you to take a look to the existing ProxyPass iRule on CodeShare. It has a really great functionality and provides most of the functionality of the original Apache ProxyPass module.
https://devcentral.f5.com/codeshare/proxypass-v10-v11
Cheers, Kai
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