Feature #1546
closedEnhancements for mod_geoip
Description
- A 'geoip.default_country_code' to be set when no matching country could be found.
- A 'geoip.force_lowercase' to be set to force all returned country codes in lowercase.
- Environment variables to be picked up and used in mod_redirect targets.
Example of combined usage:
geoip.db-filename = "/usr/share/GeoIP/GeoIP.dat" geoip.memory-cache = "enable" $HTTP["host"] =~ "^(www\.example\.com)(:[0-9]+)?$" { geoip.default_country_code = "us" geoip.force_lowercase = "enable" url.redirect = ( "^/$" => "http://%1%2/#GEOIP_COUNTRY_CODE#/", ) }
This allows us to do in-server redirects based on GeoIP country codes. I know the patches aren't ideal (changes only done for country codes for example), but they might be useful to someone nevertheless. It beats using a PHP script, but some LUA might also do the trick. These patches are quite old, but have been in large scale production for over a year now without problems.
Files
Updated by stbuehler almost 17 years ago
lighttpd-1.4.13... is a "little bit" old ;-)
- I think your patch split is not good - there are default_country parts in lowercase.patch.
OTOH, I think both patches are good, so perhaps you don't need to split them. - I don't think the redirect patch should be used - mod_magnet ;-)
- Why do you use snprintf with a const limit if you know the size of the buffer and the string?
- buffer_reset(x) shouldn't be necessary before a buffer_copy_*(x, *)
- Can you explain why you disabled mod_geoip_subrequest for p->handle_subrequest_start ?
- I think
if (buffer_is_equal_string(du->key, CONST_STR_LEN("geoip.default_country_code"))) {
could be
else if (buffer_is_equal_string(du->key, CONST_STR_LEN("geoip.default_country_code"))) {
BTW: Does anyone know why the mod is not upstream? Does it contain blocking io-code?
Updated by spillgroup almost 17 years ago
This was one of the first changes done by our (external) development team to the Lightty code. Sorry if the quality is not that good. Regarding the use of mod_magnet instead of mod_redirect: wouldn't that impose a lot more overhead?
Updated by stbuehler about 16 years ago
- Target version changed from 1.4.20 to 1.4.21
Updated by ism almost 16 years ago
Any chance this makes it to 1.4.20? can keep running the patch manually but would be nice if it's part of the version
Updated by icy almost 16 years ago
- Target version changed from 1.4.21 to 1.4.22
- Patch available set to Yes
Updated by stbuehler almost 16 years ago
- Target version changed from 1.4.22 to 1.4.23
Updated by stbuehler over 15 years ago
- Target version changed from 1.4.23 to 1.4.x
There is no mod_geoip upstream yet.
Until this happens you could discuss this on Docs:ModGeoip
Updated by stbuehler about 15 years ago
- Category changed from core to 3rd party
- Assignee deleted (
jan) - Target version deleted (
1.4.x) - Missing in 1.5.x set to No
Updated by gstrauss over 8 years ago
- Status changed from New to Wontfix
mod_geoip currently hooks subrequest_start, where the geoip info is then available to dynamic handlers such as mod_cgi, mod_fastcgi, mod_scgi.
The patches attached here move the hook to uri_clean, much earlier in the request process, effectively adding a database lookup to all requests, even for static content. Moving the hook earlier means that the geoip info is available to other handlers, besides the dynamic handlers, but adds a cost to everyone not using geoip for such purposes.
While these patches might be useful to some people, the patches are unlikely to be integrated.
As suggested above by stbuehler, if you need to do dynamic routing based on geoip info, then another option is to use mod_magnet to run a lua script to do a geoip lookup and url rewriting.
Updated by gstrauss over 8 years ago
- Related to Bug #1976: geoip env + lua added
Updated by gstrauss over 3 years ago
- ASK QUESTIONS IN Forums set to No
FYI: since lighttpd 1.4.45 (Jan 2017), lighttpd populates the request env on demand for dynamic modules, including mod_magnet, so info from mod_maxminddb (successor to mod_geoip) is available in mod_magnet
Updated by gstrauss 12 months ago
- Status changed from Wontfix to Fixed
Since lighttpd 1.4.45, most features are available via mod_magnet and a custom lua script, and using mod_maxminddb (successor to mod_geoip)
Also available in: Atom