nginx上的$geoip_城市变量不起作用

nginx上的$geoip_城市变量不起作用,nginx,geoip,Nginx,Geoip,我在Centos 6.7 final上安装了nginx-1.12.1。已在配置参数上加载--with-http\u geoip\u模块 我在http上下文中的nginx.conf上有这段代码 geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat; 还要添加此代码 map $geoip_city $not_allowed_region { default no; Shanghai yes; } 在我的vhost conf文件

我在Centos 6.7 final上安装了nginx-1.12.1。已在配置参数上加载--with-http\u geoip\u模块

我在http上下文中的nginx.conf上有这段代码

geoip_city     /usr/local/share/GeoIP/GeoLiteCity.dat;
还要添加此代码

map $geoip_city $not_allowed_region {
    default no;
    Shanghai yes;
}
在我的vhost conf文件中

# server content
if ($not_allowed_region = yes) {
   rewrite ^/(.*)$ https://test.com redirect;
}
我做了nginx-t,并使用nginx-s重新加载重新启动,但什么也没发生