http {

    # Specify the data file path
    ipip_db /root/ipip.datx 60m; # 60 minute auto reload db file

    server {
        listen       80;
        server_name  localhost;

        # Specifies the IP address to parse, Default $remote_addr
        ipip_parse_ip $http_x_forwarded_for;

        location / {
            if ($ipip_country_code = HK) {
                return 403;
            }

            if ($ipip_country_code ~* "(MO|TW)") {
                return 403;
            }

            if ($ipip_country_code !~ CN) {
                return 403;
            }                

            add_header ip $http_x_forwarded_for;
            add_header country_code $ipip_country_code;
            add_header country $ipip_country_name;
            add_header province $ipip_region_name;
            add_header city $ipip_city_name;
            add_header owner $ipip_owner_domain;
            add_header isp $ipip_isp_domain;
            add_header latitude $ipip_latitude;
            add_header longitude $ipip_longitude;
        
            root   html;
            index  index.html index.htm;
        }
    }    
}