To get htaccess like user authentication on Nginx, add the following to your site config:
auth_basic "Restricted";
auth_basic_user_file <password_file_location>;
If you want the authentication to be applied on all locations, place it in the top scope of the config. If you want it specific to a location, just add it in the scope of that location.
printf "John:$(openssl passwd -crypt <PASSWORD>)\n"
NOTE: I'm not sure about how secure that thing is.