AnoopAlias / AUTOM8N

AUTOM8N is a WHM/cPanel plugin providing a DNS load-balanced, high available, horizontally scaling webstack and offering active-active-redundancy-high-availability-and-native-nginx-on-cpanel
https://autom8n.com/
GNU General Public License v3.0
107 stars 53 forks source link

GeoIP Support #108

Closed mhhakim closed 7 years ago

mhhakim commented 7 years ago

Dear Sir, Mod GeoIP is not working on my cPanel server with nDeploy. Please help me.

Thanks

AnoopAlias commented 7 years ago

The geoip module is shipped in the rpm and enabled. But the settings are commented out as you need to install GeoIP itself and include its path

Please check /etc/nginx/conf.d/http_settings.conf

You will see

# GeoIP
# Uncomment to enable
#geoip_country         /usr/share/GeoIP/GeoLiteCountry.dat;
#geoip_city            /usr/share/GeoIP/GeoLiteCity.dat;

You need to point the dat files to the correct location where its installed.

mhhakim commented 7 years ago

I have already do this.

# GeoIP
# Uncomment to enable
geoip_country /usr/share/GeoIP/GeoIP.dat;

check https://natokhd.com/phpinfo.php GeoIP showing wrong information.

mhhakim commented 7 years ago

Before using nDeploy, I was installed GeoIP following https://www.mattgibson.ca/compiling-mod_geoip2-use-easyapache-4-ea4-cpanel/ the tutorial. I use the latest cPanel/WHM with EA4.

AnoopAlias commented 7 years ago

nginx pass the info to php using fastcgi_params in /etc/nginx/fastcgi_params

#GeoIP
fastcgi_param GEOIP_ADDR $remote_addr;
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_REGION_NAME $geoip_region_name;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_AREA_CODE $geoip_area_code;
fastcgi_param GEOIP_LATITUDE $geoip_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_ORGANIZATION $geoip_org;

I see that you are using proxy to apache..in that case the information in geoip is not passed to apache directly ..but apache use the connecting IP (which is nginx in this case )

You need to adjust your apache geoip settings to consider the proxy

http://dev.maxmind.com/geoip/legacy/mod_geoip2/#Proxy-Related_Directives

or you can switch to a PHP backend in which case nginx will directly serve content and get geoip info forwarded via fastcgi_params to php-fpm

mhhakim commented 7 years ago

If I switch PHP backend, url rewrite rule doesn't work. I already learned that I need to make rewrite rule working for nginx. Can you tell me what will be the file name of nginx rewrite rule? eg: in apache there .htaccess, what should be on nginx?

AnoopAlias commented 7 years ago

Please use the plugin user interface from cpanel. You can switch to MANUAL mode in plugin and add custom rewrite rules