项目作者: fgsch

项目描述 :
A Varnish VMOD to query MaxMind GeoIP2 DB files
高级语言: C
项目地址: git://github.com/fgsch/libvmod-geoip2.git
创建时间: 2014-07-27T00:25:57Z
项目社区:https://github.com/fgsch/libvmod-geoip2

开源协议:BSD 2-Clause "Simplified" License

下载


libvmod-geoip2

ci
codecov

About

A Varnish master VMOD to query MaxMind GeoIP2 DB files.

For Varnish 6.0, 7.4 and 7.5 refer to main branch. Older Varnish
versions are no longer supported.

Requirements

To build this VMOD you will need:

  • make
  • a C compiler, e.g. GCC or clang
  • pkg-config
  • python3-docutils or docutils in macOS [1]
  • Varnish master built from sources
  • libmaxminddb-dev in recent Debian/Ubuntu releases, maxminddb in
    macOS [1]. See also https://github.com/maxmind/libmaxminddb

If you are building from Git, you will also need:

  • autoconf
  • automake
  • libtool

You will also need to set PKG_CONFIG_PATH to the directory where
varnishapi.pc is located before running autogen.sh and
configure. For example:

  1. export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Finally, to use it you will need one or more GeoIP2 or GeoLite2
binary databases. See https://dev.maxmind.com/.

Installation

From a tarball

To install this VMOD, run the following commands:

  1. ./configure
  2. make
  3. make check
  4. sudo make install

The make check step is optional but it’s good to know whether the
tests are passing on your platform.

From the Git repository

To install from Git, clone this repository by running:

  1. git clone --recursive https://github.com/varnishcache-friends/libvmod-geoip2

And then run ./autogen.sh followed by the instructions above for
installing from a tarball.

Packages

See https://github.com/varnishcache-friends/libvmod-geoip2/wiki#packages.

Example

  1. import geoip2;
  2. sub vcl_init {
  3. new country = geoip2.geoip2("/path/to/GeoLite2-Country.mmdb");
  4. }
  5. sub vcl_recv {
  6. if (country.lookup("country/names/en", client.ip) != "Japan") {
  7. ...
  8. }
  9. }

More examples available at https://github.com/varnishcache-friends/libvmod-geoip2/wiki.

DB updates

To update the GeoIP2 DB, download the new file on the same filesystem
as the old one and move it over. See also
https://github.com/maxmind/geoipupdate.

License

This VMOD is licensed under BSD license. See LICENSE for details.

Note

  1. Using Homebrew, https://github.com/Homebrew/brew/.