chaizhenhua / ngx-ip2location

Nginx IP2Location Module
BSD 2-Clause "Simplified" License
23 stars 19 forks source link

Installed but not using the variables #5

Closed bertalanimre closed 8 years ago

bertalanimre commented 9 years ago

Hey Chaizhenhua!

Thanks for the great module for NginX. However I can't use it somewhy. After make && make install I've added to the config: html { .... ip2location_database /home/NginX/database-ip2loc/IP2LOCATION-LITE-DB1.BIN;
add_header CC $ip2location_country_code; add_header CN $ip2location_country_name; ... server { ... location / { ... if ( $ip2location_country_code = "HU" ) {return 403;} } ...etc

The index.php shows me correctly and I don't get the 403 error nor any other error.

I saw a Module Configuration part in your guide, can you axplain that part a bit more detailed please? Did I skip that part?

Cheers! Bert

bertalanimre commented 9 years ago

Partly my bad, I've forgot the example file. But now whenever I want to run nginx it gives the following error: nginx: [emerg] unknown directive "ip2location" in /usr/local/nginx/conf/nginx.conf:15

Any idea?

bertalanimre commented 9 years ago

Again helping myself. :) I've recompiled again from scratch, somehow now the above perrors are gone. Now, the only issue is that with the example index.php I get strange values only: COUNTRY_SHORT => "-" COUNTRY_LONG => "-" REGION => "" CITY => "" ISP => "0.000000" LATITUDE => "0.000000" LONGITUDE => "" DOMAIN => "" ZIPCODE => "" TIMEZONE => "" NETSPEED => "" IDDCODE => "" AREACODE => "" WEATHERSTATIONCODE => "" WEATHERSTATIONNAME => "" MCC => "" MNC => "" MOBILEBRAND => "" ELEVATION => "0.000000" USAGETYPE => ""

tjegan commented 9 years ago

You should pass the ip2location variables to PHP in your virtual hosts .php location settings. And you are using the wrong variable in your condition to block countries. It should be $ip2location_country_short instead of $ip2location_country_code

bertalanimre commented 9 years ago

Sorted it out. It was mainly local issue. The NginX recieved out firewalls IP address that looks like 10.X.X.X. OFC this isn't in the database. :D When I've installed it on a VPS in the outsideworld it worked. So sorry for giving an issue. :) :+1:

My only issue now is that I have 1 server with 2 IP addresses. One for local language and the other is for the English language of a website. When I try to redirect the local Country clients to the 1st domain, something gives me a ERR_TOO_MANY_REDIRECTS error. If I redirect them to a common place like google, it works. But I can't redirect the user from 1 URL to another on the same server :/

chaizhenhua commented 8 years ago

@bertalanimre sorry for reply so late. did you resolved the TOO_MANY_REDIRECTS error?

bertalanimre commented 8 years ago

Yes, I did. Thank you.