Forum Discussion
Matt_108113
Nimbostratus
Mar 11, 2009IRules setting for http redirect then rewrite response
I am working with Oracle istore behind an F5 and basically we are trying to use the F5 as a reverse proxy and do something like this.
customer url: http://istore.cust.com
actual ...
hoolio
Cirrostratus
Mar 11, 2009Here is an example which allows you to proxy an external site to an internal one by updating the domain in the requested host header and in the response Location header:
iRule to change host headers
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=1991719925 (Click here)
when RULE_INIT {
Set the hostname that the client makes request to (do not include protocol)
set ::external_hostname "www.mycompany.co.uk"
Set the hostname that the BIG-IP will rewrite requests to
set ::internal_hostname "www.provider.com"
Log debug messages to /var/log/ltm? 1=yes, 0=no.
set ::proxy_site_debug 1
}
when HTTP_REQUEST {
if {$::proxy_site_debug}{log local0. "Received request from [IP::client_addr] -> [HTTP::host][HTTP::uri]"}
if {$::proxy_site_debug}{log local0. "Rewriting [IP::client_addr]'s Host header to $::internal_hostname"}
Rewrite the Host header
HTTP::header replace "Host" $::internal_hostname
}
when HTTP_RESPONSE {
Check if the status indicates a redirect
if {[HTTP::is_redirect]} {
if {$::proxy_site_debug}{log local0. "Rewriting [IP::client_addr]'s redirect to \
[string map -nocase $::internal_hostname $::external_hostname [HTTP::header Location]]"}
Rewrite the Location header replacing the internal hostname with the external hostname
HTTP::header replace Location [string map -nocase $::internal_hostname $::external_hostname [HTTP::header Location]]
}
}
Or if you want more complete functionality, take a look at the ProxyPass iRule in the Codeshare (Click here).
Aaron
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