nginx uses similar syntax to that of Apache to allow users to access a directory, depending if their IP or username/pass matches (i.e. you want all users to present a valid username/pass match, but want to let some automated checks coming from specified IPs through, i.e. from ldirectord or nagios). Here is an example to use both HTTP basic auth and IP based auth.
You can create/modify the auth_basic_user_file with htpasswd program (typically found in apache2-utils or apache-base package, depending on the distribution):