[solved] SetEnvIf Alternative

Discussion in 'General' started by ballotcan, Oct 8, 2012.

  1. ballotcan

    ballotcan New Member

    Hi I'm using cloudflare + litespeed

    Code:
    SetEnvIf CF-IPCountry CN BuzzOff=1
     SetEnvIf CF-IPCountry RU BuzzOff=1
     SetEnvIf CF-IPCountry IN BuzzOff=1
     Order allow,deny
     Allow from all
     Deny from env=BuzzOff
    
    just tried that as said as this site : http://www.asiteaboutnothing.net/c_block-countries.html

    any way to use this header for block access? :confused:
    Last edited by a moderator: Oct 11, 2012
  2. mistwang

    mistwang LiteSpeed Staff

    you can use a rewrite rule to do the same thing.
  3. ballotcan

    ballotcan New Member

    any example?
  4. NiteWave

    NiteWave Administrator

    per the link you provided, CF-IPCountry is a request header.

    RewriteCond %{HTTP:CP-IPCountry} ^(CN|RU|IN)$
    RewriteRule .* - [F,L]
  5. ballotcan

    ballotcan New Member

    Thanks this works but how can i bypass this rewrite rule if there is no CP-IPCountry :confused:
    sometimes i need access to server without cloudflare protection and there won't be CP-IPCountry header
  6. NiteWave

    NiteWave Administrator

    then how do you know the IP is from which country ?
  7. ballotcan

    ballotcan New Member

    i cant know

    RewriteCond %{HTTP:CP-IPCountry} !^(DE|NL|)$
    RewriteRule .* - [F,L]

    this worked

Share This Page