Forum Discussion
irule for x forwarder
Hi,
You can also use switch or a datagroup :
using SWITCH :
when HTTP_REQUEST {
switch [HTTP::host] {
"name1.apps.abc.com" -
"namex.apps.abc.com" {
HTTP::header remove "X-Forwarded-For"
or do nothing
}
default {
HTTP::header insert "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]
}
}
}
Using DATAGROUPS
when HTTP_REQUEST {
if { [class match [HTTP::host] contains X_FORWARD_HOST] } {
HTTP::header insert "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]
} else {
HTTP::header remove "X-Forwarded-For"
or do nothing
}
}
Once you know the logic of those commands, you can choose the way you want to manage your exceptions.
Hi,
If you have only one exception so I suggest to use a single if condition with the host exception in direct within the irule code.
If you have several exceptions, you can thing implementing the switch version of the irule.
And if you have lot of exceptions, I recommend to use datagroups.
For single if condition :
when HTTP_REQUEST {
if { !([HTTP::host] eq "name1.apps.abc.com") } {
HTTP::header insert "X-Forwarded-For" [getfield [IP::client_addr] "%" 1]
}
}Hope it helps you to make your choice.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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