Call GeoIP2 Extension module in Nginx to handle visits from different countries

Source: Internet
Author: User
Tags openssl git clone maxmind

The following is the Nginx installation configuration

(1) The LIBMAXMINDDB dependent library needs to be installed first. LIBMAXMINDDB is a C library file that reads Maxmind DB files, including GeoIP2 data files under Maxmind.

$ cd/usr/local/src
$ git clone--recursive https://github.com/maxmind/libmaxminddb
$ CD LIBMAXMINDDB
$./bootstrap
$./configure
$ make
$ make Install
$ sh-c "Echo/usr/local/lib >>/etc/ld.so.conf.d/local.conf"
$ ldconfig
(2) Recompile the Ngx_http_geoip2_module module. The original Nginx band –with-http_geoip_module used is the first generation of GeoIP (GEOIP1). GEOIP2 is not yet joined in the module.


#获取ngx_http_geoip2_module
#cd/usr/local/src && git clone--recursive https://github.com/leev/ngx_http_geoip2_module
#查看原nginx编译参数
# nginx-v
Nginx version:nginx/1.6.2
Built by GCC 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
TLS SNI Support Enabled
Configure arguments:--prefix=/opt/webserver/nginx--without-http_memcached_module--user=www--group=www-- With-http_image_filter_module--with-http_stub_status_module--with-http_ssl_module--with-http_gzip_static_ Module--WITH-OPENSSL=/USR/LOCAL/SRC/OPENSSL-1.0.1J--with-zlib=/usr/local/src/zlib-1.2.8--with-pcre=/usr/local/ src/pcre-8.36--with-http_sub_module--add-module=/usr/local/src/nginx-accesskey-2.0.3--with-http_realip_module- -with-http_mp4_module
#添加模块, recompile compilation Nginx
#cd/usr/local/src/nginx-1.6.2 &&
./configure--prefix=/opt/webserver/nginx \
--without-http_memcached_module \
--USER=WWW \
--GROUP=WWW \
--with-http_image_filter_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--WITH-OPENSSL=/USR/LOCAL/SRC/OPENSSL-1.0.1J \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-pcre=/usr/local/src/pcre-8.36 \
--with-http_sub_module \
--add-module=/usr/local/src/nginx-accesskey-2.0.3 \
--add-module=/usr/local/src/ngx_http_geoip2_module \
--with-http_realip_module \
--with-http_mp4_module &&
Make
#备份原nginx程序文件
#mv/opt/webserver/nginx/sbin/nginx/opt/webserver/nginx/sbin/nginx.bak &&
\CP Objs/nginx/opt/webserver/nginx/sbin/nginx &&
Nginx-t
#测试没有问题, upgrade Nginx
#make Upgrade

(3) Simple configuration nginx.conf sample

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.