The Apache Haus Forum

Forum Topics => Third-party Modules => Topic started by: chromerep on June 26, 2013, 02:32:31 AM

Title: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on June 26, 2013, 02:32:31 AM
I download Mod GeoIP 1.2.8 for Apache 2.4.x x64 from AH.But,it shows can't load mod_geoip.so at conf file.I make a try to download Mod GeoIP 1.2.7 for Apache 2.4.x x64 from AH,it runs well.

Does it something wrong with Mod GeoIP 1.2.8 for Apache 2.4.x x64? ;)
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 26, 2013, 07:17:59 AM
Possibly, what version of Windows are you running?

It's not loading on my XP x86, but loads fine on my Vista x86. I realize your talking x64 though. I think I'll put 1.2.7b back on the download page anyway.
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 26, 2013, 10:31:37 PM
I run it under win 2008R2 server(apache2.4).And,I find it can't set allowed country code either both 1.2.7 and 1.2.8 via http://dev.maxmind.com/geoip/legacy/mod_geoip2/ (http://dev.maxmind.com/geoip/legacy/mod_geoip2/).Is there any right directive to provide to tuning?
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 26, 2013, 11:31:47 PM
Code: [Select]
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE MX AllowCountry
# ... place more countries here
<Directory "/path/to/some/website">
# your Options and AllowOverrides and anything else
Require env AllowCountry
</Directory>

I believe the above should work in 2.4

I'm surprised 1.2.8 doesn't load in 2008R2, It should in Vista and up. Do you get a "The specified procedure could not be found." in the error message?
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: DnvrSysEngr on June 27, 2013, 03:43:09 AM
I have it running on a 32-bit Windows 2008 server.  Made no changes whatsoever to my .conf files when upgrading from 1.2.7b to 1.2.8.

 - S
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 27, 2013, 06:22:45 AM
Gregg:

Can you post Block country full directives fro httpd.conf use? :)
The allowed directives works fine.And,I need the block directives too.

Code: [Select]
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE CA AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE MX AllowCountry
# ... place more countries here
<Directory "/path/to/some/website">
# your Options and AllowOverrides and anything else
Require env AllowCountry
</Directory>
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 27, 2013, 11:54:48 AM
If I remember correctly, it was

Code: [Select]
SetEnvIf GEOIP_COUNTRY_CODE US BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE CA BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE MX BlockCountry
# ... place more countries here
<Directory "/path/to/some/website">
# your Options and AllowOverrides and anything else
  <RequireAll>
    Require all granted
    Require not env BlockCountry
  </RequireAll>
</Directory>

although I do see this in my config

Code: [Select]
  <RequireAll>   
    Require all granted
    <RequireNone>
      Require env BlockCountry
    </RequireNone>
  </RequireAll>   
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 27, 2013, 12:21:09 PM
Thanks.And..
Would yould please to fix mod_geoip1.2.8 for 2008R2 x64 to use?
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: DnvrSysEngr on June 27, 2013, 06:32:11 PM
Gregg:

I can concur that there is an issue with the 64-bit Mod_GeoIP module.  I have a 64-bit Windows8 development box running the 64-bit version of Apache 2.4.4.  I replaced Mod_GeoIP 1.2.7b with 1.2.8 and Apache 2.4.4 would not start.  The moment I reverted back to 1.2.7b, Apache 2.4.4 started.

 - S
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 27, 2013, 07:35:15 PM
OK, thanks for the reports. Am pulling 1.2.8 now. Look for 1.2.8a in the near future.
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 27, 2013, 09:48:47 PM
OK, 1.2.8a is available. I hope these work for you. It's impossible to get any kind of debugging data on windows short of installing a full version of Visual C++. So if I cannot duplicate the problem, it's hard to track it down.
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 28, 2013, 01:26:41 AM
Mod_geoip1.2.8a works under 2008R2 now. :)

And,what is the directive of allowed ip(such as private ip...or another blockcountry ip..) at blockcountry setting.I try to use "allow from 192.168.0.0/16" directive,but not works.
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: mario on June 28, 2013, 06:12:43 PM
Allow from is not 2.4 style. Use the require style.

Require ip 192.168
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 28, 2013, 11:43:20 PM
It shows "systax error and unknown authz provider" when use "require" directive under apache2.4.4 ::)

So strange?
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 29, 2013, 05:05:02 AM
is mod_authz_host loaded?
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 29, 2013, 09:31:50 AM
I turn off mod_authz_host,but it shows syntax error when I use "require".I can't believe it can accept allow and deny directives under apache2.4.x still.I am sure I use apache 2.4.x now.Though I load mod_access_compat for compatibility with old configurations.

I should use both allow and require directives.Isn't it?
But,the allow from 192.168.0.0/16 doesn't take effects.I can't understand..
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: Gregg on June 29, 2013, 09:48:36 AM
Is it apache 2.4.4 bug?

No.

To use Require, mod_authz_core must be loaded!
http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require
See in the box at the top of the docs for Require, where it says "Module: mod_authz_core"

To use Require ip or Require host, mod_authz_host must be loaded
http://httpd.apache.org/docs/2.4/mod/mod_authz_host.html

Yes, you can use Order/Allow/Deny in 2.4 if mod_access_compat is loaded. I have found that you can not use both Require and Order/Allow/Deny in your config. One of them will win and usually Require loses the fight. So if you are using both, anything configured with Require will 403.

It is recommended to use Require only in 2.4 and just unload mod_access_compat.
Title: Re: Mod GeoIP 1.2.8 for Apache 2.4.x x64 can't load
Post by: chromerep on June 29, 2013, 12:37:44 PM
Thanks.
I unload mod_access_compat and load mod_authz_core,mod_authz_host,it can run the "require" directive now.

But,I require ip X.X.X.X from blockcountry code,it can't access to the web.
Does it mean the require ip not to take effects?
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on June 29, 2013, 07:13:07 PM
Post your require statements so I can see what you have. It should still allow the IP but it may depend on what you are doing.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on June 30, 2013, 04:04:40 AM
my require statements:
<IfModule geoip_module>
GeoIPEnable On
GeoIPEnableUTF8 On
GeoIPScanProxyHeaders On
GeoIPUseLastXForwardedForIP On
GeoIPOutput Env
GeoIPDBFile /path/GeoIP.dat
SetEnvIf GEOIP_COUNTRY_CODE XX BlockCountry
<Directory "/path/to/some/website">
Require ip X.X.X.X
<RequireAll>   
    Require all granted
    <RequireNone>
      Require env BlockCountry
    </RequireNone>
  </RequireAll>
</Directory>
</IfModule>
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on June 30, 2013, 06:51:06 AM
try
<RequireAll>   
    Require all granted
    Require ip X.X.X.X
    <RequireNone>
      Require env BlockCountry
    </RequireNone>
  </RequireAll>

Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 02, 2013, 08:40:33 AM
It works now.But,the loading of web page become unstable when load the mod_geoip.The web's component(such as icon,images...) can't load normally.Some become unloaded.

I make a try,I unload the mod_geoip,the web page loads normally.

Maybe it's mod_geoip's minor issue?And,is the mod_geoip same as the maxmind provieded?(http://dev.maxmind.com/geoip/legacy/mod_geoip2/ (http://(http://dev.maxmind.com/geoip/legacy/mod_geoip2/))Can AH compile this version? :)
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on July 02, 2013, 11:03:49 AM
Yes, it is that version.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on July 02, 2013, 08:48:16 PM
You know, this version isn't 100%. As a matter of fact, I have not ever had a version of mod_geoip that was ever 100%. A problem is that if you look at a typical request, the majority will be correct, but some will not. So if you are using mod_geoip to block, then some things may not show up.

I use mod_geoip mainly for knowing where visitors come from, nothing more. I add the country to the end of each line in my access log. Doing this, I can see that it fails on occasion. For instance, if you go to my server's index.html page, it will make 14 requests, index.html, 3 fonts and 10 images. Looking at one such request in today's log I have:

203.147.5.xxx
10 of the 14 say Thailand, 1 United States, 1 Greece, 1 Bhutan and one that came back as nothing.

Obviously Thailand is the correct one, but if I had a block on the country Bhutan, this visitor wouldn't get the image /icons/blank.gif.

This problem was discussed before here (https://forum.apachehaus.com/index.php?topic=710.0). I got to thinking about this after my short answer that this is the latest version.

I think if I really cared to block a country, I'd only block the .html, .php and any other similar file like that. I've never seen the first request fail to the server fail, and blocking these files would not stop images loading for people that were allowed to see the .html/php/etc. files because a mod_geoip failed on a subsequent request.

Just a thought.

Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 02, 2013, 11:34:04 PM
Yeah.Your thought is a good way to think.

If I just want to block the country to view "php/html..",what is the directives it need to add the conf file?Can you post a detail sample for me to reference?I can't find that at maxmind documents.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on July 03, 2013, 12:15:17 AM
No, you will not find an example at maxmind, but you do have an example in your conf making the viewing/downloading of .ht(access|passwd) files impossible. There are also a lot of examples of access control in the Apache docs, you just use a little imagination with what you know.

Outside of any virtualhost or directory containers, you may be able to use something similar to:

<Files ~ "\.(html?|php|cgi)$">
    #Put your access stuff here
</Files>
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 01:20:42 AM
In this sample,how to block some country codes to access php/html only..except icon,images..?I am so fool to figure out it.(I check apache access control documents before)Can give any advanced sample?

<Files ~ "\.(html?|php|cgi)$">
    #Put your access stuff here
</Files>
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 03, 2013, 02:15:29 AM
I find that using mod_geoip is a great way to keep unwanted visitors from certain countries.  I am mean in that i block visitors from certain countries from viewing everything.  I do not want them to have the opportunity to even begin to search for any sort of exploit/s nor do i want them to scavenge any info to use for their spamming / bots / hacks / etc.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: Gregg on July 03, 2013, 07:22:05 AM
chromerep, how about replacing
#Put your access stuff here

with

<RequireAll>   
    Require all granted
    Require ip X.X.X.X
    <RequireNone>
      Require env BlockCountry
    </RequireNone>
</RequireAll>
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 09:18:11 AM
After add those directives,the former web loading issue occurs again.It seems the mod_geoip issue,can't get resolved untile turn it off.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 03, 2013, 06:01:57 PM
Here is how mine is configured, if this may shed any light towards a resolution.

<Directory>
 SetEnvIf GEOIP_COUNTRY_CODE 1 BlockCountry
 SetEnvIf GEOIP_COUNTRY_CODE 2 BlockCountry
 SetEnvIf GEOIP_COUNTRY_CODE 3 BlockCountry
 
     Substitute the numbers with actual country codes

 <RequireAll>
  Require all granted
  <RequireNone>
   Require env BlockCountry
  </RequireNone>
 </RequireAll>
</Directory>
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 11:02:48 PM
Here are some error log from mod_geoip at httpd.conf:
Code: [Select]
GeoIP: Error Traversing Database for ipnum = 3410457733 - Perhaps database is corrupt?
GeoIP: Error Traversing Database for ipnum = :: - Perhaps database is corrupt?
GeoIP: Error Traversing Database for ipnum = 3410457607 - Perhaps database is corrupt?
GeoIP: Error Traversing Database for ipnum = 3410457607 - Perhaps database is corrupt?
GeoIP: Error Traversing Database for ipnum = :: - Perhaps database is corrupt?

I google it,and find this post concerned about it's bug.(http://forum.maxmind.com/viewtopic.php?t=1056)

The bug appears again??
But,I don't think this issue concerned about web loading abnormally.It's another issue need to be fixed.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 11:05:40 PM
My config is the same as yours.But,after load mod_geoip,the web component (icon,images,css..etc)can't load normally.


Here is how mine is configured, if this may shed any light towards a resolution.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 03, 2013, 11:21:09 PM
I forgot to mention that my production version and config which I posted for you and work flawlessly are from a 32-bit version.

If I get time, I will try with the 64-bit version of my dev server over the 4th of July weekend and see if I encounter the same issue/s.

 - S
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 11:26:54 PM
You can reproduce it,but I find some php scripts has this issue,some has not.I can't say it's all php scrips causes it.It's because the mod_geoip should suit for mostly php scripts like other apache module does.


If I get time, I will try with the 64-bit version of my dev server over the 4th of July weekend and see if I encounter the same issue/s.

Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 03, 2013, 11:30:24 PM
Here is what I have in my httpd.conf file for Mod_GeoIP (64-bit):

LoadModule geoip_module modules/mod_geoip.so

<IfModule geoip_module>
 GeoIPEnable On
 # Specify full path to the database here!
 # Use only one database.
 # GeoIPDBFile /path/to/GeoIP.dat
 # GeoIPDBFile /path/to/GeoLiteCity.dat
 # IPv6 support use two databases
 GeoIPDBFile bin/GeoIPv6.dat
 #GeoIPDBFile bin/GeoLiteCity.dat
</IfModule>

my GeoIPv6.dat file is loaded in the bin directory per the instructions.  If you are not running IPv6, then you only need the GeoIP.dat file.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 03, 2013, 11:49:09 PM
DnvrSysEngr,
Thanks for your conf.
My conf for mod_geoip is the same.I think it should not the configuration issue to cause the web loading abnormal issue after loading mod_geoip.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 04, 2013, 04:50:32 AM
Trying to decipher the cryptic explanations is almost pointless.  None really give a clear reason nor a clear answer.  However, some point to it being related to the GeoIP database. 
Maybe you could try going to:

     http://dev.maxmind.com/geoip/legacy/geolite/

and downloading the database you need and placing it into your bin directory and seeing if that resolves the issue?
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 04, 2013, 05:39:38 AM
I tried to download those geoip data files before.But,can't resolve this web issue.
I think it's mod_geoip to cause.
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: DnvrSysEngr on July 04, 2013, 06:18:33 AM
Try rolling back to Mod_GeoIP 1.2.7?

Also, what happens if you try to access the site you are having issues with via "localhost?"

 - S
Title: Re: Mod GeoIP 1.2.8 directive for Apache 2.4.x x64 can't run
Post by: chromerep on July 04, 2013, 11:55:01 PM
I roll back to 1.2.7,but it's the same till unload mod_geoip.
I can't figure out what happens.

Maybe it has something that stop the web component to load.