Forum Discussion
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:
ProxyPass /foo http://host.domain.tld/bar
I need something like this:
if {[HTTP::uri] eq "/foo"}{
pool target_pool /bar
}
But this is not available.
I tried this but this is not handy because /bar can also be a location on local
if {[HTTP::uri] eq "/foo"}{
HTTP::redirect /bar
pool target_pool
}
Any suggestions?
Cheers Christian
Hi Christian,
to translate the
while forwarding the request to your internal server, you could use the rather simple iRule below. The[HTTP::uri]
command will simply strip the first four chars (e.g.[string range]
) from the original URI and substitute the internal path (e.g./foo
) into a new/bar
value.[HTTP::uri]
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
values on each request and untranslate[HTTP::header value Referer]
,[HTTP::header value Location]
,[HTTP::header value Content-Location]
,[HTTP::cookie domain]
and even embeded links in[HTTP::cookie path]
on each response to reflect the external URI namespace.[HTTP::payload]
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
* 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