linux:nginx

Nginx

geoip

# updated geoip list https://mailfud.org/geoip-legacy/ 
#/etc/nginx/conf.d/geoip.conf
geoip_country         /usr/share/GeoIP/GeoIP.dat;
 
    # Define a variable to check if the client is from Russia
    map $geoip_country_code $is_russia {
        default no;
        RU yes;
    }
 
    # Define a variable to check if the client IP is within the 10.59.0.0/16 range
    geo $is_local {
        default no;
        10.59.0.0/16 yes;
    }
 
    # Combine the checks into a single variable
    map "$is_russia$is_local" $allowed {
        default no;
        yesno yes;
        noyes yes;
    }
 
 
 
#block on geo
#server.conf
    if ($allowed = no) {
        return 403;
   }
  • linux/nginx.txt
  • Last modified: 2024/10/16 16:24
  • by admin