Forum Discussion

Jaspreetgurm's avatar
Jaspreetgurm
Icon for Altocumulus rankAltocumulus
Jul 14, 2021

Blocking Traffic based on Geo Location

I have requirement to block the traffic to a particular https path (Page) via iRule on WAF device in order to restrict the access of below url from all other geo location aspect Thailand country .

 

Can someone help on this. I have write below iRule.

 

 

when HTTP_REQUEST {

  if { [string tolower [HTTP::uri]] equals "http://abc.com/job-request/" && [whereis [IP::client_addr] country] ne "TH" } {

    drop

{

else {

#log local0. "The page is restricted"

}

}

7 Replies

  • iRule looks fine with few modifcations to uri and closing braces. Also, please check with the requestor if it should be explicit URL "/job-request/" or wildcard (i.e anything after) "/job-request*".

    If it's a wildcard, replace "eq" with "starts_with"

    when HTTP_REQUEST {
     if { ([string tolower [HTTP::uri]] eq "/job-request") and ([whereis [IP::client_addr] country] ne "TH") } {
      drop
     }  else {
       return
      }
    }
     
     
     
     
    • Jaspreetgurm's avatar
      Jaspreetgurm
      Icon for Altocumulus rankAltocumulus

      Thanks Sanjay for replying.

       

      /"/job-request" is specific path which needs to be restricted. So could you please advise if eq is suffice the needs or shall this change to starts_with ?