Forum Discussion
richard_arthur_
Nimbostratus
Feb 02, 2016Use HTTP_Referer to select pool
Trying to figure out iRules here to help the app team. They want to use the HTTP_Referer to select which pool to use. Is that possible? IS the below code close to correct? Thanks.
This is...
cjunior
Nacreous
Feb 02, 2016Hi, URI::host does not include that protocol, so you could try this way:
when HTTP_REQUEST {
if { [HTTP::header value Referer] starts_with "http://remotepay-pt.test.com" } {
pool REMOTEPAY_7080
} else {
pool REMOTEPAY_80
}
}
You may not need two iRules by checking VS port:
when HTTP_REQUEST {
if { [URI::host [HTTP::header value Referer]] eq "remotepay-pt.test.com" } {
if { [TCP::local_port] eq 80 } {
pool REMOTEPAY_7080
} else {
pool REMOTEPAY_7443
}
} else {
if { [TCP::local_port] eq 80 } {
pool REMOTEPAY_80
} else {
pool REMOTEPAY_443
}
}
}
Also, you might want to validate that the Referer header exists, e.g.
if { [HTTP::header exists Referer] and
[HTTP::header value Referer] starts_with "http://remotepay-pt.test.com" }
To get the protocol from Referer:
set proto [URI::protocol [HTTP::header value Referer]]
https://devcentral.f5.com/wiki/iRules.URI.ashx
Respectfully,
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
