Forum Discussion
dihris_116090
May 28, 2016Nimbostratus
HTTP Rewrite header + pool based on URI
Hi,
I need to forward traffic from external URL to one of our internal servers based on URI. That has to be transparent for the browser with no redirect messages 3xx.
Searching in the forum and u...
- May 28, 2016
Hi,
here an rule example :
when RULE_INIT { set external_hostname "externalsite.com" set internal_hostname "internalsite.com" } when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { Disable the stream filter for requests STREAM::disable Remove this header to prevent server from compression response HTTP::header remove Accept-Encoding if { ([string tolower [HTTP::path]] eq "/foobar") } { HTTP::host [string map {$external_hostname $internal_hostname} [HTTP::host]] pool internal_pool } else { pool $default_pool } } when HTTP_RESPONSE { Rewrite the Location header for redirects if { [HTTP::header exists Location] }{ HTTP::header replace Location [string map {$external_hostname $internal_hostname} [HTTP::header Location]] } Rewrite the response content using a stream profile if it is text if { [HTTP::header Content-Type] contains "text" } { Set the stream expression with the find/replace strings STREAM::expression "@xyz.company.com@abc.company.com@" Enable the stream filter STREAM::enable } }
Yann_Desmarest_
Nacreous
Hi,
here an rule example :
when RULE_INIT {
set external_hostname "externalsite.com"
set internal_hostname "internalsite.com"
}
when CLIENT_ACCEPTED {
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
Disable the stream filter for requests
STREAM::disable
Remove this header to prevent server from compression response
HTTP::header remove Accept-Encoding
if { ([string tolower [HTTP::path]] eq "/foobar") } {
HTTP::host [string map {$external_hostname $internal_hostname} [HTTP::host]]
pool internal_pool
} else {
pool $default_pool
}
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {$external_hostname $internal_hostname} [HTTP::header Location]]
}
Rewrite the response content using a stream profile if it is text
if { [HTTP::header Content-Type] contains "text" } {
Set the stream expression with the find/replace strings
STREAM::expression "@xyz.company.com@abc.company.com@"
Enable the stream filter
STREAM::enable
}
}
dihris_116090
May 28, 2016Nimbostratus
Hi Yann, thank you for your response. I've created stream profile and added to the VS. Installed the iRule though it does not seem to be working. As with the iRule from Odaah I do not see the header getting changed. I take it under STREAM::expression I neeed to change the find/replace string to @$internalsite.com@$externalsite.com@ ?
What logging should I put to see exactly where the iRule brakes?
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