hexasoft icon

Block country with IP2Location Nginx Module

hexasoft | PRO | 04/19/18 11:00:49 PM UTC | 0 ⭐ | 7324 👁️ | Never ⏰ | []
Nginx |

220 B

|

None

|

0 👍

/

0 👎

server {
    .
    .
    .
    
    if ( $ip2location_country_code = CN ) {
        set $need_block Y;
    }
 
    if ( $remote_addr = 1.2.3.4 ) {
        set $need_block N;
    }
 
    if ( $need_block = Y ) {
        return 403;
        break;
    }
 
    .
    .
    .
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎