Advertisement
hexasoft

Block country with IP2Location Nginx Module

Apr 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 0.22 KB | None | 0 0
  1. server {
  2.     .
  3.     .
  4.     .
  5.    
  6.     if ( $ip2location_country_code = CN ) {
  7.         set $need_block Y;
  8.     }
  9.  
  10.     if ( $remote_addr = 1.2.3.4 ) {
  11.         set $need_block N;
  12.     }
  13.  
  14.     if ( $need_block = Y ) {
  15.         return 403;
  16.         break;
  17.     }
  18.  
  19.     .
  20.     .
  21.     .
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement