See https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/#combining-basic-authentication-with-access-restriction-by-ip-address for how to accomplish that. The file that needs to be touched is https://github.com/ise621/machine/blob/main/nginx/templates/default.conf.template