auth_ldap_servers
`auth_ldap_servers` 指令定义了 NGINX 可用于用户身份验证的 LDAP 服务器。
LDAP Authentication module for NGINX
·
httpserverlocationlimit_except
语法auth_ldap_servers server_name;
默认值none
上下文http, server, location, limit_except
参数any
说明
auth_ldap_servers 指令是 NGINX 的 LDAP Authentication 模块的一部分,该模块允许 Web 服务器针对一个或多个 LDAP 服务器对用户进行身份验证。通过在 server、location 或 http 上下文中指定此指令,管理员可以配置 NGINX 去引用外部 LDAP 服务器,以用于验证用户凭据。每个服务器可以用特定的连接参数定义,例如 URL、bind DN 和其他认证条件。 \n\n可以定义多个 LDAP server 块,且它们应当以 ldap_server 指令开头,该指令指定了用于认证用户的连接详细信息和要求。随后必须设置 auth_ldap 指令以启用认证并指定显示给用户的 realm 消息。该指令支持多种参数,包括是否要求有效用户、定义组属性或管理连接重试策略等设置。\n\n在实现 auth_ldap_servers 时,一个重要的考虑是确保所有定义的服务器都可达且已根据您的网络和安全策略正确配置。这可能包括管理 SSL 证书验证,以便与 LDAP 服务器建立安全连接。
配置示例
http {
ldap_server test1 {
url ldap://192.168.0.1:3268/DC=test,DC=local?sAMAccountName?sub?(objectClass=person);
binddn "TEST\\LDAPUSER";
binddn_passwd LDAPPASSWORD;
group_attribute uniquemember;
group_attribute_is_dn on;
require valid_user;
}
server {
listen 8000;
server_name localhost;
auth_ldap "Forbidden";
auth_ldap_servers test1;
location / {
root html;
index index.html index.htm;
}
}
}⚠
确保服务器地址可从 NGINX 主机访问。
⚠
错误的 LDAP URLs 会导致连接问题;在使用前请验证它们。
⚠
配置错误的 binddn 或 binddn_passwd 会导致身份验证失败。