title: How to authenticate nginx with ldap?
body: <p>I follow this reference <a href="https://github.com/kvspb/nginx-auth-ldap/blob/master/README.md" rel="nofollow noreferrer">https://github.com/kvspb/nginx-auth-ldap/blob/master/README.md</a> and try to integrate nginx and LDAP.</p>
  
  <p>my nginx.conf setting:</p>
  
  <pre><code>user  nginx;
  worker_processes  4;
  
  error_log  /var/log/nginx/error.log warn;
  pid        /var/run/nginx.pid;
  events {
      worker_connections  1024;
  }
  
  http {
          ldap_server ldap_local {
          url "ldap://localhost/cn=Manager,dc=xinhua?uid?sub?(objectClass=posixAccount)";
          binddn "cn=Manager,dc=xinhua,dc=org";
          binddn_passwd "xxxxxx";
          require group "cn=config,ou=People,dc=xinhua,dc=org";
          group_attribute "memberUid";
          group_attribute_is_dn off;
          require valid_user;
          satisfy all;
  }
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      keepalive_timeout  65;
  
      #gzip  on;
      include /etc/nginx/conf.d/*.conf;
  }
  </code></pre>
  
  <p>conf.d/default.conf</p>
  
  <pre><code>server {
      listen       8000;
      server_name  localhost;
  
      #charset koi8-r;
      #access_log  /var/log/nginx/host.access.log  main;
      auth_ldap "Forbidden";
      auth_ldap_servers ldap_local;
  
      location / {
          root   /usr/share/nginx/html;
          index  index.html index.htm;
      }
  
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /usr/share/nginx/html;
      }
  }
  </code></pre>
  
  <p>My question is how to authenticate the username and password which are in LDAP.
  <img src="https://user-images.githubusercontent.com/19474557/42205680-b4fabe92-7ed7-11e8-9979-643dce5bcd66.png" /></p>
  
  <p><img src="https://user-images.githubusercontent.com/19474557/42205713-c4a15f9a-7ed7-11e8-947d-429e85632d10.png" /></p>
  
  <p>This is my first time to use LDAP.</p>
  
  <p>Now, I don't know what is the username and password.</p>
  
  <p>When I try the username and password in <code>.htpasswd</code>. It doesn't work.</p>