Forum Discussion
Irule not working as expected with variable
Friends,
Could someone help me with below Irule , were I am trying to see in Geodb if the client ip is part of countries CU,IR,KP,SD,SY,UA or state Sevastopol,Krym in that case set a SEC variable to value .Based on that value have header insert as well if there exists Forwarded-For header take content/values of that and insert into custom header.
Thanks all in advance, Shivesh
Irule
when CLIENT_ACCEPTED { set srcip [IP::client_addr] set country [whereis $srcip country] set region [whereis $srcip state] switch [whereis $srcip country ] { "CU" - "IR" - "KP" - "SD" - "SY" - "UA" [whereis $srcip state ] { "Sevastopol'" - "Krym" { set SEC 1 } { set SEC 0 } } } } when HTTP_REQUEST { switch {[HTTP::header values "X-Forwarded-For"] ne ""{ HTTP::header insert "ABCD-INFRA-OrigXFF" [HTTP::header values "X-Forwarded-For" ]}} HTTP::header replace ABCD-INFRA-XFF [$srcip] HTTP::header replace X-Forwarded-For [$srcip] switch $SEC { "1" { HTTP::header insert ABCD-INFRA-IPI $srcip HTTP::header insert ABCD-INFRA-GeoCountry $country HTTP::header insert ABCD-INFRA-GeoRegion $region HTTP::header insert ABCD-INFRA-SEC True } "0" { HTTP::header insert ABCD-INFRA-IPI $srcip HTTP::header insert ABCD-INFRA-GeoCountry $country HTTP::header insert ABCD-INFRA-GeoRegion $region HTTP::header insert ABCD-INFRA-SEC False } } }
1 Reply
- Vijay_E
Cirrus
Use the "preformatted code" button - 4th from left when posting code. This will make it better readable.
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