Hi Alex,
you can do it that way or use something like this
inside your server {} block:
allow IP1;
allow IP2;
allow IP3;
deny all;
http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,266738,266750#msg-266750