# Geoip+php

**URL:** <https://www.ruby-forum.com/t/geoip-php/216908>\
**Category:** NGINX\
**Created:** [February 16, 2012, 6:56pm UTC](https://www.ruby-forum.com/t/geoip-php/216908 "2012-02-16T18:56:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [February 16, 2012, 6:56pm UTC](https://www.ruby-forum.com/t/geoip-php/216908/1 "2012-02-16T18:56:25Z")

</div>

Hi. I’d want to secure some locations with basic GeoIP like this:

/etc/nginx/sites-enabled/default\_server

upstream error {  
server localhost:9222;  
}  
server {  
root /var/www/htdocs;  
server\_name 10.10.10.10;  
listen 80;  
include /etc/nginx/fastcgi\_php;  
location / {  
index index.php;  
}

```
    error_page 403 /403.html;
    location = /403.html {
            root /var/www/nginx-default;
    }

    location ^~ /test {
           index index.php;

    if ($geoip_country_code = AR) {
    fastcgi_pass unix:/var/run/www/php.sock;
    }

    if ($geoip_country_code != AR) {
    fastcgi_pass error;
    return 403;
    }

    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
include /etc/nginx/fastcgi.conf;  
}  
}

It’s working but images are not displaying. If I switch my location to  
^~ /test.php$ my GeoIP stops working. 😃

Any suggestions?  
Thanks
