rpms/lighttpd/F-7 lighttpd-1.4.18-mod_geoip.patch, NONE, 1.1 lighttpd-mod_geoip.c, NONE, 1.1 lighttpd-mod_geoip.txt, NONE, 1.1 lighttpd.spec, 1.36, 1.37
Matthias Saou (thias)
fedora-extras-commits at redhat.com
Tue Mar 4 11:08:45 UTC 2008
- Previous message (by thread): rpms/lighttpd/EL-4 lighttpd-1.4.18-Fix-372-and-1562.patch, NONE, 1.1 lighttpd-1.4.18-mod_cgi-fix.patch, NONE, 1.1 lighttpd-1.4.18-mod_geoip.patch, NONE, 1.1 lighttpd-mod_geoip.c, NONE, 1.1 lighttpd-mod_geoip.txt, NONE, 1.1 lighttpd.spec, 1.9, 1.10
- Next message (by thread): rpms/lighttpd/EL-5 lighttpd-1.4.18-Fix-372-and-1562.patch, NONE, 1.1 lighttpd-1.4.18-mod_cgi-fix.patch, NONE, 1.1 lighttpd-1.4.18-mod_geoip.patch, NONE, 1.1 lighttpd-mod_geoip.c, NONE, 1.1 lighttpd-mod_geoip.txt, NONE, 1.1 lighttpd.spec, 1.35, 1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: thias
Update of /cvs/extras/rpms/lighttpd/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14024
Modified Files:
lighttpd.spec
Added Files:
lighttpd-1.4.18-mod_geoip.patch lighttpd-mod_geoip.c
lighttpd-mod_geoip.txt
Log Message:
Backport geoip module from F-8/devel branches.
lighttpd-1.4.18-mod_geoip.patch:
--- NEW FILE lighttpd-1.4.18-mod_geoip.patch ---
diff -Naupr lighttpd-1.4.18.orig/src/Makefile.am lighttpd-1.4.18/src/Makefile.am
--- lighttpd-1.4.18.orig/src/Makefile.am 2007-09-03 00:23:53.000000000 +0200
+++ lighttpd-1.4.18/src/Makefile.am 2007-10-16 19:13:56.000000000 +0200
@@ -241,6 +241,11 @@ mod_accesslog_la_SOURCES = mod_accesslog
mod_accesslog_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_accesslog_la_LIBADD = $(common_libadd)
+lib_LTLIBRARIES += mod_geoip.la
+mod_geoip_la_SOURCES = mod_geoip.c
+mod_geoip_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
+mod_geoip_la_LIBADD = $(common_libadd) -lGeoIP
+
hdr = server.h buffer.h network.h log.h keyvalue.h \
response.h request.h fastcgi.h chunk.h \
diff -Naupr lighttpd-1.4.18.orig/src/Makefile.in lighttpd-1.4.18/src/Makefile.in
--- lighttpd-1.4.18.orig/src/Makefile.in 2007-09-09 21:55:29.000000000 +0200
+++ lighttpd-1.4.18/src/Makefile.in 2007-10-16 19:16:47.000000000 +0200
@@ -126,6 +126,12 @@ mod_accesslog_la_OBJECTS = $(am_mod_acce
mod_accesslog_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(mod_accesslog_la_LDFLAGS) $(LDFLAGS) -o $@
+mod_geoip_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am_mod_geoip_la_OBJECTS = mod_geoip.lo
+mod_geoip_la_OBJECTS = $(am_mod_geoip_la_OBJECTS)
+mod_geoip_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(mod_geoip_la_LDFLAGS) $(LDFLAGS) -o $@
mod_alias_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_mod_alias_la_OBJECTS = mod_alias.lo
mod_alias_la_OBJECTS = $(am_mod_alias_la_OBJECTS)
@@ -413,7 +419,7 @@ SOURCES = $(liblightcomp_la_SOURCES) $(m
$(mod_userdir_la_SOURCES) $(mod_usertrack_la_SOURCES) \
$(mod_webdav_la_SOURCES) $(lemon_SOURCES) $(lighttpd_SOURCES) \
$(lighttpd_angel_SOURCES) $(proc_open_SOURCES) \
- $(spawn_fcgi_SOURCES)
+ $(spawn_fcgi_SOURCES) $(mod_geoip_la_SOURCES)
DIST_SOURCES = $(am__liblightcomp_la_SOURCES_DIST) \
$(mod_access_la_SOURCES) $(mod_accesslog_la_SOURCES) \
$(mod_alias_la_SOURCES) $(mod_auth_la_SOURCES) \
@@ -433,7 +439,7 @@ DIST_SOURCES = $(am__liblightcomp_la_SOU
$(mod_usertrack_la_SOURCES) $(mod_webdav_la_SOURCES) \
$(lemon_SOURCES) $(am__lighttpd_SOURCES_DIST) \
$(lighttpd_angel_SOURCES) $(proc_open_SOURCES) \
- $(spawn_fcgi_SOURCES)
+ $(spawn_fcgi_SOURCES) $(mod_geoip_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -614,7 +620,7 @@ lib_LTLIBRARIES = $(am__append_1) mod_fl
mod_ssi.la mod_secdownload.la mod_expire.la mod_evhost.la \
mod_simple_vhost.la mod_fastcgi.la mod_extforward.la \
mod_access.la mod_compress.la mod_auth.la mod_rewrite.la \
- mod_redirect.la mod_status.la mod_accesslog.la
+ mod_redirect.la mod_status.la mod_accesslog.la mod_geoip.la
@NO_RDYNAMIC_TRUE at liblightcomp_la_SOURCES = $(common_src)
@NO_RDYNAMIC_TRUE at liblightcomp_la_CFLAGS = $(AM_CFLAGS)
@NO_RDYNAMIC_TRUE at liblightcomp_la_LDFLAGS = -avoid-version -no-undefined
@@ -721,6 +727,9 @@ mod_status_la_LIBADD = $(common_libadd)
mod_accesslog_la_SOURCES = mod_accesslog.c
mod_accesslog_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_accesslog_la_LIBADD = $(common_libadd)
+mod_geoip_la_SOURCES = mod_geoip.c
+mod_geoip_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
+mod_geoip_la_LIBADD = $(common_libadd) -lGeoIP
hdr = server.h buffer.h network.h log.h keyvalue.h \
response.h request.h fastcgi.h chunk.h \
settings.h http_chunk.h http_auth_digest.h \
@@ -822,6 +831,8 @@ mod_access.la: $(mod_access_la_OBJECTS)
$(mod_access_la_LINK) -rpath $(libdir) $(mod_access_la_OBJECTS) $(mod_access_la_LIBADD) $(LIBS)
mod_accesslog.la: $(mod_accesslog_la_OBJECTS) $(mod_accesslog_la_DEPENDENCIES)
$(mod_accesslog_la_LINK) -rpath $(libdir) $(mod_accesslog_la_OBJECTS) $(mod_accesslog_la_LIBADD) $(LIBS)
+mod_geoip.la: $(mod_geoip_la_OBJECTS) $(mod_geoip_la_DEPENDENCIES)
+ $(mod_geoip_la_LINK) -rpath $(libdir) $(mod_geoip_la_OBJECTS) $(mod_geoip_la_LIBADD) $(LIBS)
mod_alias.la: $(mod_alias_la_OBJECTS) $(mod_alias_la_DEPENDENCIES)
$(mod_alias_la_LINK) -rpath $(libdir) $(mod_alias_la_OBJECTS) $(mod_alias_la_LIBADD) $(LIBS)
mod_auth.la: $(mod_auth_la_OBJECTS) $(mod_auth_la_DEPENDENCIES)
@@ -1043,6 +1054,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/md5.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_access.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_accesslog.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_geoip.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_alias.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_auth.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mod_cgi.Plo at am__quote@
--- NEW FILE lighttpd-mod_geoip.c ---
#include <GeoIP.h>
#include <GeoIPCity.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "base.h"
#include "log.h"
#include "buffer.h"
#include "plugin.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/**
*
* $mod_geoip.c (v2.0) (13.09.2006 00:29:11)
*
* Name:
* mod_geoip.c
*
* Description:
* GeoIP module (plugin) for lighttpd.
* the module loads a geoip database of type "country" or "city" and
* sets new ENV vars based on ip record lookups.
*
* country db env's:
* GEOIP_COUNTRY_CODE
* GEOIP_COUNTRY_CODE3
* GEOIP_COUNTRY_NAME
*
* city db env's:
* GEOIP_COUNTRY_CODE
* GEOIP_COUNTRY_CODE3
* GEOIP_COUNTRY_NAME
* GEOIP_CITY_NAME
* GEOIP_CITY_POSTAL_CODE
* GEOIP_CITY_LATITUDE
* GEOIP_CITY_LONG_LATITUDE
* GEOIP_CITY_DMA_CODE
* GEOIP_CITY_AREA_CODE
*
* Usage (configuration options):
* geoip.db-filename = <path to the geoip or geocity database>
* geoip.memory-cache = <enable|disable> : default disabled
* if enabled, mod_geoip will load the database binary file to
* memory for very fast lookups. the only penalty is memory usage.
*
* Author:
* Ami E. Bizamcher (amix)
* duke.amix at gmail.com
*
* Note:
* GeoIP Library and API must be installed!
*/
/* plugin config for all request/connections */
typedef struct {
unsigned short mem_cache;
buffer *db_name;
GeoIP *gi;
} plugin_config;
typedef struct {
PLUGIN_DATA;
plugin_config **config_storage;
plugin_config conf;
} plugin_data;
/* init the plugin data */
INIT_FUNC(mod_geoip_init) {
plugin_data *p;
p = calloc(1, sizeof(*p));
return p;
}
/* detroy the plugin data */
FREE_FUNC(mod_geoip_free) {
plugin_data *p = p_d;
UNUSED(srv);
if (!p) return HANDLER_GO_ON;
if (p->config_storage) {
size_t i;
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s = p->config_storage[i];
if (!s) continue;
buffer_free(s->db_name);
/* clean up */
GeoIP_delete(s->gi);
free(s);
}
free(p->config_storage);
}
free(p);
return HANDLER_GO_ON;
}
/* handle plugin config and check values */
SETDEFAULTS_FUNC(mod_geoip_set_defaults) {
plugin_data *p = p_d;
size_t i = 0;
config_values_t cv[] = {
{ "geoip.db-filename", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
{ "geoip.memory-cache", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
if (!p) return HANDLER_ERROR;
p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s;
int mode;
s = calloc(1, sizeof(plugin_config));
s->db_name = buffer_init();
s->mem_cache = 0; /* default: do not load db to cache */
s->gi = NULL;
cv[0].destination = s->db_name;
cv[1].destination = &(s->mem_cache);
p->config_storage[i] = s;
if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) {
return HANDLER_ERROR;
}
mode = GEOIP_STANDARD | GEOIP_CHECK_CACHE;
/* country db filename is requeried! */
if (!buffer_is_empty(s->db_name)) {
/* let's start cooking */
if (s->mem_cache != 0)
mode = GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE;
if (NULL == (s->gi = GeoIP_open(s->db_name->ptr, mode))) {
log_error_write(srv, __FILE__, __LINE__, "s",
"failed to open GeoIP database!!!");
return HANDLER_ERROR;
}
/* is the db supported ? */
if (s->gi->databaseType != GEOIP_COUNTRY_EDITION &&
s->gi->databaseType != GEOIP_CITY_EDITION_REV0 &&
s->gi->databaseType != GEOIP_CITY_EDITION_REV1) {
log_error_write(srv, __FILE__, __LINE__, "s",
"GeoIP database is of unsupported type!!!");
}
}
}
return HANDLER_GO_ON;
}
#define PATCH(x) \
p->conf.x = s->x;
static int mod_geoip_patch_connection(server *srv, connection *con, plugin_data *p) {
size_t i, j;
plugin_config *s = p->config_storage[0];
PATCH(db_name);
PATCH(mem_cache);
PATCH(gi);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
data_config *dc = (data_config *)srv->config_context->data[i];
s = p->config_storage[i];
/* condition didn't match */
if (!config_check_cond(srv, con, dc)) continue;
/* merge config */
for (j = 0; j < dc->value->used; j++) {
data_unset *du = dc->value->data[j];
if (buffer_is_equal_string(du->key, CONST_STR_LEN("geoip.db-filename"))) {
PATCH(db_name);
}
if (buffer_is_equal_string(du->key, CONST_STR_LEN("geoip.memory-cache"))) {
PATCH(mem_cache);
}
}
}
return 0;
}
#undef PATCH
URIHANDLER_FUNC(mod_geoip_subrequest) {
plugin_data *p = p_d;
mod_geoip_patch_connection(srv, con, p);
if (!buffer_is_empty(p->conf.db_name)) {
const char *remote_ip;
GeoIP *gi;
data_string *ds;
const char *returnedCountry;
remote_ip = inet_ntop_cache_get_ip(srv, &(con->dst_addr));
if (p->conf.gi->databaseType == GEOIP_COUNTRY_EDITION) {
/* get the country code 2 chars */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_CODE"))) {
if (NULL != (returnedCountry = GeoIP_country_code_by_addr(p->conf.gi, remote_ip))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_CODE");
buffer_copy_string(ds->value, returnedCountry);
array_insert_unique(con->environment, (data_unset *)ds);
}
}
/* get the country code 3 chars */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_CODE3"))) {
if (NULL != (returnedCountry = GeoIP_country_code3_by_addr(p->conf.gi, remote_ip))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_CODE3");
buffer_copy_string(ds->value, returnedCountry);
array_insert_unique(con->environment, (data_unset *)ds);
}
}
/* get the country name */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_NAME"))) {
if (NULL != (returnedCountry = GeoIP_country_name_by_addr(p->conf.gi, remote_ip))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_NAME");
buffer_copy_string(ds->value, returnedCountry);
array_insert_unique(con->environment, (data_unset *)ds);
}
}
/* go on... */
return HANDLER_GO_ON;
}
/* if we are here, geo city is in use */
GeoIPRecord * gir;
if (NULL != (gir = GeoIP_record_by_addr(p->conf.gi, remote_ip))) {
/* get the country code 2 chars */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_CODE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_CODE");
buffer_copy_string(ds->value, gir->country_code);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the country code 3 chars */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_CODE3"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_CODE3");
buffer_copy_string(ds->value, gir->country_code3);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the country name */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_COUNTRY_NAME"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_COUNTRY_NAME");
buffer_copy_string(ds->value, gir->country_name);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the city region */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_REGION"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_CITY_REGION");
buffer_copy_string(ds->value, gir->region);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the city */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_NAME"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_CITY_NAME");
buffer_copy_string(ds->value, gir->city);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the postal code */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_POSTAL_CODE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
buffer_copy_string(ds->key, "GEOIP_CITY_POSTAL_CODE");
buffer_copy_string(ds->value, gir->postal_code);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the latitude */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_LATITUDE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
char latitude[32];
sprintf(&latitude, "%f", gir->latitude);
buffer_copy_string(ds->key, "GEOIP_CITY_LATITUDE");
buffer_copy_string(ds->value, latitude);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the long latitude */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_LONG_LATITUDE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
char long_latitude[32];
sprintf(&long_latitude, "%f", gir->longitude);
buffer_copy_string(ds->key, "GEOIP_CITY_LONG_LATITUDE");
buffer_copy_string(ds->value, long_latitude);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the dma code */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_DMA_CODE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
char dc[5];
sprintf(&dc, "%i", gir->dma_code);
buffer_copy_string(ds->key, "GEOIP_CITY_DMA_CODE");
buffer_copy_string(ds->value, dc);
array_insert_unique(con->environment, (data_unset *)ds);
}
/* get the area code */
if (NULL == (ds = (data_string *)array_get_element(con->environment, "GEOIP_CITY_AREA_CODE"))) {
if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
ds = data_string_init();
}
char ac[5];
sprintf(&ac, "%i", gir->area_code);
buffer_copy_string(ds->key, "GEOIP_CITY_AREA_CODE");
buffer_copy_string(ds->value, ac);
array_insert_unique(con->environment, (data_unset *)ds);
}
}
}
/* keep walking... (johnnie walker style ;) */
return HANDLER_GO_ON;
}
/* this function is called at dlopen() time and inits the callbacks */
int mod_geoip_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = buffer_init_string("geoip");
p->init = mod_geoip_init;
p->handle_subrequest_start = mod_geoip_subrequest;
p->set_defaults = mod_geoip_set_defaults;
p->cleanup = mod_geoip_free;
p->data = NULL;
return 0;
}
--- NEW FILE lighttpd-mod_geoip.txt ---
==============================
ip based geographic lookups...
==============================
-----------------
Module: mod_geoip
-----------------
.. contents:: Table of Contents
Requirements
============
:Packages: GeoIP C API & Library (http://www.maxmind.com/download/geoip/api/c/)
Overview
============
mod_geoip is a module for fast ip/location lookups. It uses MaxMind GeoIP / GeoCity databases.
If the ip was found in the database the module sets the appropriate environments variables to the request, thus making other modules/fcgi be informed.
.. note::
Currently only country/city databases are supported because they have a free version that i can test.
(http://www.maxmind.com/download/geoip/database/ - GeoIP.dat.gz for Countries, GeoLiteCity.dat.gz for Countries & Cities)
Installation
============
NOTE: As of 1.4.14 the lighttpd distribution does not include the compile file required to perform a automake in the source directory. Use "automake -a" instead.
1) Download mod_geoip.c (http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.c)
- (for lighttpd 1.5 use http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.4.c and rename it to mod_geoip.c)
2) Copy mod_geoip.c into lighttpd src directory.
3) Edit your src/Makefile.am and add this after the last module:
::
lib_LTLIBRARIES += mod_geoip.la
mod_geoip_la_SOURCES = mod_geoip.c
mod_geoip_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_geoip_la_LIBADD = $(common_libadd) -lGeoIP
4) Go back to lighttpd root directory and first do: aclocal && automake -a && autoconf, after that do: make clean; ./configure --enable-maintainer-mode; make; make install
Note: the command of 'make clean' gives error on Fedora 4 and may not be necessary to compile properly. [j lightstone//GlobalAdSales.company]
5) Make sure /usr/local/lib is in your ld.so.conf file and rebuld the ld database (using: ldconfig).
6) Add to the config file server.modules = ("mod_geoip") [j lightstone//GlobalAdSales.company]
Configuration Options
========================
NOTE: in lighttpd 1.5.x add the config vars only to the global config - adding into a vhost crashes lighty!
mod_geoip uses two configuration options.
1) geoip.db-filename = <path to the geoip or geocity database>
2) geoip.memory-cache = <enable|disable> : default disabled
if enabled, mod_geoip will load the database binary file to
memory for very fast lookups. the only penalty is memory usage.
.. note::
mod_geoip will determine the database type automatically so if you enter GeoCity databse path it will load GeoCity Env.
Environment
===========
Every database sets it's own ENV:
GeoIP (Country):
----------------
::
GEOIP_COUNTRY_CODE
GEOIP_COUNTRY_CODE3
GEOIP_COUNTRY_NAME
GeoCity:
--------
::
GEOIP_COUNTRY_CODE
GEOIP_COUNTRY_CODE3
GEOIP_COUNTRY_NAME
GEOIP_CITY_NAME
GEOIP_CITY_POSTAL_CODE
GEOIP_CITY_LATITUDE
GEOIP_CITY_LONG_LATITUDE
GEOIP_CITY_DMA_CODE
GEOIP_CITY_AREA_CODE
Examples
========
mod_geoip + php
---------------
NOTE: in lighttpd 1.5.x add the config vars only to the global config - adding into a vhost crashes lighty!
when using fastcgi (not only php) you can access mod_geoip env and do as you please. this example just prints all mod_geoip envs to the client, html.
Config-file ::
geoip.db-filename = "/your-geoip-db-path/GeoLiteCity.dat"
geoip.memory-cache = "enable"
index.php ::
<?php
$country_code = $_SERVER['GEOIP_COUNTRY_CODE'];
$country_code3 = $_SERVER['GEOIP_COUNTRY_CODE3'];
$country_name = $_SERVER['GEOIP_COUNTRY_NAME'];
$city_region = $_SERVER['GEOIP_CITY_REGION'];
$city_name = $_SERVER['GEOIP_CITY_NAME'];
$city_postal_code = $_SERVER['GEOIP_CITY_POSTAL_CODE'];
$city_latitude = $_SERVER['GEOIP_CITY_LATITUDE'];
$city_long_latitude = $_SERVER['GEOIP_CITY_LONG_LATITUDE'];
$city_dma_code = $_SERVER['GEOIP_CITY_DMA_CODE'];
$city_area_code = $_SERVER['GEOIP_CITY_AREA_CODE'];
echo "<html>\n<body>\n\t<br>\n";
echo 'Country Code: ' . $country_code . '<br>';
echo 'Country Code 3: ' . $country_code3 . '<br>';
echo 'Country Name: ' . $country_name . '<br>';
echo '<br>';
echo 'City Region: ' . $city_region . '<br>';
echo 'City Name: ' . $city_name . '<br>';
echo 'City Postal Code: ' . $city_postal_code . '<br>';
echo 'City Latitude: ' . $city_latitude . '<br>';
echo 'City Long Latitude: ' . $city_long_latitude . '<br>';
echo 'City DMA Code: ' . $city_dma_code . '<br>';
echo 'City Area Code: ' . $city_area_code . '<br>';
echo "</body>\n</html>";
?>
country based redirect
----------------------
Config-file ::
$HTTP["host"] =~ "www.domain.com" {
url.rewrite = ( "" => "/redirect.php")
}
redirect.php ::
<?php
$country_code = $_SERVER['GEOIP_COUNTRY_CODE'];
header ('Location: http://' . $country_code . '.domain.com/');
?>
.. note::
Currently it is not possible to redirect based on mod_geoip directly in lighttpd config file. But i believe with the relase of lighttpd mod_magnet it would be. (mod_magnet will be available in lighttpd 1.4.12+)
Downloads
=========
mod_geoip.c (http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.c)
mod_geoip.c for lighttpd 1.5.x (http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModGeoip/mod_geoip.4.c)
Index: lighttpd.spec
===================================================================
RCS file: /cvs/extras/rpms/lighttpd/F-7/lighttpd.spec,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- lighttpd.spec 4 Mar 2008 10:44:13 -0000 1.36
+++ lighttpd.spec 4 Mar 2008 11:07:50 -0000 1.37
@@ -3,7 +3,7 @@
Summary: Lightning fast webserver with light system requirements
Name: lighttpd
Version: 1.4.18
-Release: 2%{?dist}
+Release: 3%{?dist}
License: BSD
Group: System Environment/Daemons
URL: http://www.lighttpd.net/
@@ -15,7 +15,10 @@
Source12: powered_by_fedora.png
Source13: http://www.lighttpd.net/light_button.png
Source14: http://www.lighttpd.net/light_logo.png
+Source100: lighttpd-mod_geoip.c
+Source101: lighttpd-mod_geoip.txt
Patch0: lighttpd-1.4.17-defaultconf.patch
+Patch1: lighttpd-1.4.18-mod_geoip.patch
# Security fixes
Patch10: lighttpd-1.4.18-Fix-372-and-1562.patch
Patch11: lighttpd-1.4.18-mod_cgi-fix.patch
@@ -51,16 +54,6 @@
--without : ldap gdbm lua (cml)
-%package mod_mysql_vhost
-Summary: Virtual host module for lighttpd that uses a MySQL database
-Group: System Environment/Daemons
-Requires: %{name} = %{version}
-BuildRequires: mysql-devel
-
-%description mod_mysql_vhost
-Virtual host module for lighttpd that uses a MySQL database.
-
-
%package fastcgi
Summary: FastCGI module and spawning helper for lighttpd and PHP configuration
Group: System Environment/Daemons
@@ -72,11 +65,34 @@
defaults needed for correct FastCGI behavior.
+%package mod_geoip
+Summary: GeoIP module for lighttpd to use for location lookups
+Group: System Environment/Daemons
+Requires: %{name} = %{version}
+BuildRequires: GeoIP-devel
+
+%description mod_geoip
+GeoIP module for lighttpd to use for location lookups.
+
+
+%package mod_mysql_vhost
+Summary: Virtual host module for lighttpd that uses a MySQL database
+Group: System Environment/Daemons
+Requires: %{name} = %{version}
+BuildRequires: mysql-devel
+
+%description mod_mysql_vhost
+Virtual host module for lighttpd that uses a MySQL database.
+
+
%prep
%setup -q
%patch0 -p1 -b .defaultconf
+%patch1 -p1 -b .mod_geoip
%patch10 -p1 -b .Fix-372-and-1562
%patch11 -p1 -b .mod_cgi-fix
+%{__install} -p -m 0644 %{SOURCE100} src/mod_geoip.c
+%{__install} -p -m 0644 %{SOURCE101} mod_geoip.txt
%build
@@ -166,18 +182,13 @@
%{_libdir}/lighttpd/
%exclude %{_libdir}/lighttpd/*.la
%exclude %{_libdir}/lighttpd/mod_fastcgi.so
+%exclude %{_libdir}/lighttpd/mod_geoip.so
%exclude %{_libdir}/lighttpd/mod_mysql_vhost.so
%{_mandir}/man1/lighttpd.1*
%attr(0750, lighttpd, lighttpd) %{_var}/log/lighttpd/
%attr(0750, lighttpd, lighttpd) %{_var}/run/lighttpd/
%{webroot}/
-%files mod_mysql_vhost
-%defattr(-,root,root,-)
-%doc doc/mysqlvhost.txt
-%dir %{_libdir}/lighttpd/
-%{_libdir}/lighttpd/mod_mysql_vhost.so
-
%files fastcgi
%defattr(-,root,root,-)
%doc doc/fastcgi*.txt
@@ -187,12 +198,28 @@
%{_libdir}/lighttpd/mod_fastcgi.so
%{_mandir}/man1/spawn-fcgi.1*
+%files mod_geoip
+%defattr(-,root,root,-)
+%doc mod_geoip.txt
+%dir %{_libdir}/lighttpd/
+%{_libdir}/lighttpd/mod_geoip.so
+
+%files mod_mysql_vhost
+%defattr(-,root,root,-)
+%doc doc/mysqlvhost.txt
+%dir %{_libdir}/lighttpd/
+%{_libdir}/lighttpd/mod_mysql_vhost.so
+
%changelog
-* Tue Mar 4 2008 Matthias Saou <http://freshrpms.net/> 1.4.18-2
+* Tue Mar 4 2008 Matthias Saou <http://freshrpms.net/> 1.4.18-3
- Include patch for CVE-2008-0983 (crash when low on file descriptors).
- Include patch for CVE-2008-1111 (cgi source disclosure).
+* Tue Oct 16 2007 Matthias Saou <http://freshrpms.net/> 1.4.18-2
+- Include mod_geoip additional source, make it an optional sub-package.
+- Reorder sub-packages alphabetically in spec file.
+
* Mon Sep 10 2007 Matthias Saou <http://freshrpms.net/> 1.4.18-1
- Update to 1.4.18.
- Include newly installed lighttpd-angel ("angel" process meant to always run
- Previous message (by thread): rpms/lighttpd/EL-4 lighttpd-1.4.18-Fix-372-and-1562.patch, NONE, 1.1 lighttpd-1.4.18-mod_cgi-fix.patch, NONE, 1.1 lighttpd-1.4.18-mod_geoip.patch, NONE, 1.1 lighttpd-mod_geoip.c, NONE, 1.1 lighttpd-mod_geoip.txt, NONE, 1.1 lighttpd.spec, 1.9, 1.10
- Next message (by thread): rpms/lighttpd/EL-5 lighttpd-1.4.18-Fix-372-and-1562.patch, NONE, 1.1 lighttpd-1.4.18-mod_cgi-fix.patch, NONE, 1.1 lighttpd-1.4.18-mod_geoip.patch, NONE, 1.1 lighttpd-mod_geoip.c, NONE, 1.1 lighttpd-mod_geoip.txt, NONE, 1.1 lighttpd.spec, 1.35, 1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list