Whitelist IP in NGINX for URL

# ...
 server {
     listen 80;
     server_name www.example.com;


     location /accounts/login {
        allow 45.43.23.21;
        deny all;
     }

     location /api {
         limit_except GET {
             auth_basic "NGINX Plus API";
             auth_basic_user_file /path/to/passwd/file;
         }

         api   write=on;

         allow 127.0.0.1;
         deny  all;
     }
 }

sudo nginx -t
sudo service nginx reload #debian/ubuntu
systemctl restart nginx #redhat/centos