VPS business hosting starting at $29.95/24/7 premium technical support

How to whitelist IPs in NGINX configuration?

Add this code in your .conf file

if ($remote_addr = "14.51.20.3") {
  set $block_me_now "B";
}
 
 if ($remote_addr = "104.1.20.29") {
  set $block_me_now "B";
}

if ($block_me_now != "B") {
    return 403;
    break;
}

Author: Harshvardhan Malpani

PHP Developer based in New Delhi, India. Working as a freelance web developer providing server deployment, website development and maintenance services.

Leave a Reply

Your email address will not be published. Required fields are marked *