Opened 7 years ago

Closed 7 years ago

#295 closed defect (invalid)

if geoip_org bug in regxp

Reported by: Alex Storn Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.3.x
Keywords: geoip, geoip_org Cc:
uname -a: FreeBSD 10.0-CURRENT amd64
nginx -V: nginx version: nginx/1.3.12
TLS SNI support enabled
configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/ --error-log-path=/var/log/nginx-error.log --user=www --group=www --with-file-aio --with-ipv6 --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --add-module=/usr/ports/www/nginx-devel/work/agentzh-headers-more-nginx-module-6586984 --with-http_geoip_module --with-http_stub_status_module --add-module=/usr/ports/www/nginx-devel/work/naxsi-0.46-1/naxsi_src --with-pcre --with-http_ssl_module


http section

    # GeoIP
    # geoip_country   /usr/local/share/GeoIP/GeoIP.dat;        # the country IP database
    # geoip_city      /usr/local/share/GeoIP/GeoLiteCity.dat;  # the city IP database
     geoip_org       /usr/local/share/GeoIP/GeoIPASNum.dat;   # the ASN IP database

server host section

        location ~ \.php$ {
           if ($geoip_org ~* ^/(AS[0-9]+)/) {
               set $as_num $1;
           fastcgi_param GeoIP_ASN $as_num;
# cat /usr/local/bin/
fetch -o - | gunzip > /usr/local/share/GeoIP/GeoIP.dat
fetch -o - | gunzip > /usr/local/share/GeoIP/GeoIPASNum.dat
fetch -o - | gunzip > /usr/local/share/GeoIP/GeoLiteCity.dat

HTTP return "GeoIP_ASN" empty string
geoip_org not work in if contruction regexp

Change History (1)

comment:1 by Maxim Dounin, 7 years ago

Resolution: invalid
Status: newclosed

Regexp as shown in description requires "/" characters to be present in the $geoip_org, which is likely always false with the database used. I.e. empty string is perfectly correct.

Use something like this instead:

           if ($geoip_org ~* "^(AS[0-9]+)") {
               set $as_num $1;
Note: See TracTickets for help on using tickets.