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.
- SANTHOSHKUMAR_SAug 01, 2016Nimbostratus
Hi Yann , Please be more specific which rule must be ideal for my request , if my host name contain name1.apps.abc.com i should do nothing on x forwarder . If it contains any other name like name2.apps.abc.com or name3.apps.abc.com i should do x forwarder . Thanks
- Yann_DesmarestAug 01, 2016Cirrus
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.
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