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


upstream error {
server localhost:9222;
server {
root /var/www/htdocs;
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

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. :smiley:

Any suggestions?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs