Как аутентифицировать nginx с помощью ldap? - PullRequest
0 голосов
/ 03 июля 2018

Я следую этой ссылке https://github.com/kvspb/nginx-auth-ldap/blob/master/README.md и пытаюсь интегрировать nginx и LDAP.

мой параметр nginx.conf:

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;
}

conf.d / default.conf

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;
    }
}

Мой вопрос заключается в том, как аутентифицировать имя пользователя и пароль в LDAP. image

image

Я впервые использую LDAP.

Теперь я не знаю, что такое имя пользователя и пароль.

Когда я пытаюсь ввести имя пользователя и пароль в .htpasswd. Это не работает.

1 Ответ

0 голосов
/ 09 апреля 2019

Почему не через https://github.com/nginxinc/nginx-ldap-auth? Это демон, используйте что-то вроде

     location = /auth-proxy {
        internal;
        proxy_pass_request_body off;
        proxy_set_header Content-Length "";
        proxy_pass http://127.0.0.1:8888;
        proxy_set_header X-Ldap-URL "ldap://127.0.0.1:389";
        proxy_set_header X-Ldap-Template "(uid=%(username)s)";
        proxy_set_header X-Ldap-BaseDN "dc=example,dc=com";
    }
    location /private-storage {
        auth_request /auth-proxy;
        proxy_pass http://application-backend;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...