--with-http_geoip_module not showing on my configure arguments

July 24, 2017 169 views
Nginx CentOS

I need help on understanding how to configure geoip module on nginx web server, I'm using Centos 6.7 final.

This is the result of nginx -V

configure arguments: --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-httpgzipstaticmodule --with-httpstubstatusmodule --with-httpsslmodule --with-pcre --with-file-aio --with-httprealipmodule --without-httpscgimodule --without-httpuwsgimodule --without-httpfastcgimodule

I already did
./configure --with-httpgeoipmodule
make && make install

The result is:
make -f objs/Makefile
make[1]: Entering directory /nginx-1.12.1'
make[1]: Nothing to be done for
build'.
make[1]: Leaving directory /nginx-1.12.1'
make -f objs/Makefile install
make[1]: Entering directory
/nginx-1.12.1'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
|| mv '/usr/local/nginx/sbin/nginx' \
'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgiparams' \
|| cp conf/fastcgi
params '/usr/local/nginx/conf'
cp conf/fastcgiparams \
'/usr/local/nginx/conf/fastcgi
params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgiparams' \
|| cp conf/uwsgi
params '/usr/local/nginx/conf'
cp conf/uwsgiparams \
'/usr/local/nginx/conf/uwsgi
params.default'
test -f '/usr/local/nginx/conf/scgiparams' \
|| cp conf/scgi
params '/usr/local/nginx/conf'
cp conf/scgiparams \
'/usr/local/nginx/conf/scgi
params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/nginx-1.12.1'

Checked again the nginx -V. --withhttpgeoip_module is still not showing on configure argumets.

How do I know if the module is already loaded?

2 comments
  • @jtittle Do you have one of your compile instructions handy, so you can help with this?

  • Hi @hansen,

    I guess its been loaded now. I tried to compile it inside nginx ./configure folder. My problem now is geoipcity is not working tho I checked geoipcountry_code and it seems no problem.

    http {
        geoip_country  /usr/local/share/GeoIP/GeoIP.dat;
        geoip_city     /usr/local/share/GeoIP/GeoLiteCity.dat;
    
        // Working
        map $geoip_country_code $not_allowed_country {
            default no;
            US yes;
        }
    
        // Not working
        map $geoip_city $not_allowed_city {
            default no;
            Shanghai yes;
        }
    }
    
    server {
        if ($not_allowed_city = yes) {
            rewrite ^/(.*)$ https://myurl.com redirect;
        }
    }
    

    I also did nginx -t, and the result is successful. I have no idea why geoip_city is not working.

1 Answer

Hi @meowmanijado

Did you have a look at this tutorial?
https://www.digitalocean.com/community/tutorials/how-to-compile-nginx-from-source-on-a-centos-6-4-x64-vps

Also found this tutorial, which doesn't go into as many details, but still seems easy:
http://www.leeladharan.com/compiling-nginx-with-modules-pagespeed-and-geoip

by Sairam Kunala
Read how to compile Nginx from source on a CentOS 6.4 x64 VPS.
  • Hi @hansen ,

    I tried the last one, but I'm stuck on compiling. I used this code from that link your provide

    ./configure --prefix=/etc/nginx --sbindir=/usr/sbin --sysconf=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/clienttemp --http-proxy-temp-path=/var/cache/nginx/proxytemp --http-fastcgi-temp-path=/var/cache/nginx/fastcgitemp --http-uwsgi-temp-path=/var/cache/nginx/uwsgitemp --http-scgi-temp-path=/var/cache/nginx/scgitemp --user=nginx --group=nginx --with-httpsslmodule --with-httprealipmodule --with-httpadditionmodule --with-httpsubmodule --with-httpdavmodule --with-httpflvmodule --with-httpmp4module --with-httpgunzipmodule --with-httpgzipstaticmodule --with-httprandomindexmodule --with-httpsecurelinkmodule --with-httpstubstatusmodule --with-httpauthrequestmodule --with-mail --with-mailsslmodule --with-file-aio --with-ipv6 --with-httpspdymodule --with-httpgeoipmodule --with-cc-opt='-O2 -g -pipe -Wp,-DFORTIFYSOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

    I removed the pagespeed script because I don't need it. I'm getting the unrecognized option error. For example

    configure: error: unrecognized option: --pid-path=/var/run/nginx.pid

    I also checked the ./configure --help but I'm not sure what is the correct option for this directory and the following.

    FYI. I'm inside the GeoIP-1.4.8 folder, wondering if ./configure options is not the same on nginx.

Have another answer? Share your knowledge.