To protect a folder by IP address in nginx is fairly simple, see the example below that demonstrates only allowing access to the /protected folder for people in the 192.168.0.* network.
server {
....
location /protected {
allow 192.168.0.0/24;
deny all;
}
...
}