nginx +geoip

MB
На сайте с 24.02.2009
Offline
182
1168

Всем привет!

Подскажите, правильно ли я прописал в конфиге строку if ($allowed_country = no) {return 444;} ?

сначала пробовал прописывать location / {, но при таком раскладе не блокировался хотлинкинг из китая, значит нужно в секцию server { прописывать?

http {
geoip_country /usr/local/share/GeoIP/GeoIP.dat;
map $geoip_country_code $allowed_country {
default yes;
CN no;
}
include mime.types;
default_type application/octet-stream;
proxy_buffer_size 8k;
access_log off;
sendfile on;
keepalive_timeout 90;
large_client_header_buffers 8 8k;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
client_max_body_size 16m;
log_format isp '$bytes_sent $request_length';
server {
if ($allowed_country = no) {return 444;}
server_name site.com www.site.com;
listen ip;
index index.php index.html index.htm;
set $root_path /home/site/data/www/site.site;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
error_page 404 = @fallback;
}
location / {
limit_req zone=one burst=10 nodelay;
proxy_pass http://ip:81;
proxy_redirect http://ip:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
}
location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
proxy_pass http://ip:81;
proxy_redirect http://ip:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://ip:81;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
include /usr/local/ispmgr/etc/nginx.inc;
}
[Удален]
#1

map $geoip_country_code $bad_country {

default 0;
CN 1;
}
if ($bad_country) {
return 444;
}

Так удобнее :)

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий