NGINX HTTP Basic Authentication with LDAP

First,  install libpam-ldap

# apt-get install libpam-ldap

Config ldap:// properly. This will add ldap backend to PAM.

Now, create a file /etc/pam.d/nginx

@include common-auth
@include common-account

This will add nginx service in PAM.

Then, config your nginx to enable HTTP basic authentication using auth_pam and PAM service name “nginx”

location /someplace {
  auth_pam "Restricted Area";
  auth_pam_service_name nginx;
}

Restart nginx. Done.