title: How to block a page for certain countries (geoip2) without if?
body: <p>How it is possible without using <strong>if</strong> but with <strong>map</strong> in nginx with the module --with_geoip2_module (dynamic) to block all countries except the chosen and all ip except the chosen, to make it work like this:</p>
  <pre><code>**if ($lan = yes) {
                set $allowed_country yes;
        }
  
  if ($allowed_country = no) {
         return 503;
    }**
  </code></pre>
  <p>but without <strong>if</strong>?</p>
  <p><strong>Centos 7</strong></p>
  <p>It`s my /etc/nginx/nginx.conf</p>
  <pre><code>load_module modules/ngx_http_geoip2_module.so;
  
  user nginx;
  
  worker_processes  1;
  
  error_log  /var/log/nginx/error.log warn;
  
  pid        /var/run/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
  #block country
  
   geoip2 /etc/nginx/geoip/GeoLite2-Country/GeoLite2-Country.mmdb {
  
  auto_reload 60m;
  $geoip2_data_country_code country iso_code;
  $geoip2_data_country_name country names en;
  }  
  
  geo $lan {
   default no;
   123.224.55.2 yes;
  
    }
  
  
  map $geoip2_data_country_code $allowed_country {
      
      default no;
      UA yes;
      BG yes;
      RO yes;
  }
  
     log_format geoip_main '$remote_addr - $geoip2_data_country_code - $remote_user [$time_local] '
                             '&quot;$request&quot; $status $body_bytes_sent &quot;$host&quot; '
                             '&quot;$http_referer&quot; &quot;$http_user_agent&quot; &quot;$gzip_ratio&quot;';
  
  access_log  /var/log/nginx/access.log geoip_main;
  
  access_log /var/log/nginx/geoip_country.log geoip_main;
      sendfile        on;
      #tcp_nopush     on;
      keepalive_timeout  65;
  
  access_log /var/log/nginx/geoip_country.log geoip_main;
      sendfile        on;
      #tcp_nopush     on;
      keepalive_timeout  65;
  
      #gzip  on;
  
      include /etc/nginx/conf.d/*.conf;
   include include/etc/nginx/modules/*.so;
  
  }
  </code></pre>
  <p>I am very grateful to you for your help!</p>