📄 mod_ldap.html
字号:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="Apache, 中文, 手册, 中文版, 中文手册, 中文版手册, 参考手册, 中文参考手册, 金步国" />
<meta name="description" content="Apache 2.2 中文版参考手册" />
<meta name="author" content="金步国" />
<link href="../style/css/manual-zip.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-zip-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
<title>mod_ldap - Apache 2.2 中文版参考手册</title>
</head>
<body><div id="page-header">
<p class="menu"><a href="../mod/index.html">模块索引</a> | <a href="../mod/directives.html">指令索引</a> | <a href="../faq/index.html">常见问题</a> | <a href="../glossary.html">词汇表</a> | <a href="../sitemap.html">站点导航</a></p><p class="apache">Apache HTTP Server 版本2.2</p><img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
<div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">文档</a> > <a href="../index.html">版本2.2</a> > <a href="./index.html">模块</a></div>
<div id="translation-info"> <a href="../translator_announcement.html#thanks">致谢</a> | <a href="../translator_announcement.html#announcement">译者声明</a> | 本篇译者:<a href="mailto:csfrank@citiz.net">金步国</a> | 本篇译稿最后更新:?年?月?日 | <a href="../translator_announcement.html#last_new">获取最新版本</a></div>
<div id="page-content"><div id="preamble"><h1>Apache模块 mod_ldap</h1>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="module">
<tr><th><a href="module-dict.html#Description">说明</a></th><td>为其它LDAP模块提供LDAP连接池和结果缓冲服务</td></tr>
<tr><th><a href="module-dict.html#Status">状态</a></th><td>扩展(E)</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">模块名</a></th><td>ldap_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">源文件</a></th><td>util_ldap.c</td></tr>
<tr><th><a href="module-dict.html#Compatibility">兼容性</a></th><td>仅在 Apache 2.0.41 及以后的版本中可用</td></tr>
</table>
<h3>概述</h3>
<p>本模块通过后端连接LDAP服务来改善网站性能。除了标准LDAP库提供的功能外,本模块增加了一个LDAP连接池和一个LDAP共享内存缓冲区。</p>
<p>为了使用本模块的功能,LDAP支持必须编译进APU。这是通过在编译Apache时,在<code class="program"><a href="../programs/configure.html">configure</a></code>脚本命令行上增加 <code>--with-ldap</code> 开关来实现的。</p>
<p>为了支持SSL/TLS ,需要<a class="glossarylink" href="../glossary.html#apr" title="see glossary">APR</a>连接以下一个LDAP SDK :<a href="http://www.openldap.org/">OpenLDAP SDK</a>(2.x或更新), <a href="http://developer.novell.com/ndk/cldap.htm">Novell LDAP SDK</a>, <a href="http://www.mozilla.org/directory/csdk.html">Mozilla LDAP SDK</a>, 本地 Solaris LDAP SDK (基于Mozilla), 本地 Microsoft LDAP SDK, <a href="http://www.iplanet.com/downloads/developer/">iPlanet (Netscape)</a> SDK 。参见<a href="http://apr.apache.org">APR</a>网站以获取更多信息。</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="exampleconfig" id="exampleconfig">示例配置</a></h2>
<p>下面的配置是一个使用<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>模块来提升<code class="module"><a href="../mod/mod_authnz_ldap.html">mod_authnz_ldap</a></code>提供的HTTP基本认证性能的例子。</p>
<div class="example"><p><code>
# 开启LDAP连接池及共享内存缓冲。<br />
# 开启LDAP缓冲状态处理器。需要载入mod_ldap和mod_authnz_ldap模块。<br />
# 把"yourdomain.example.com"改为你真实的域名。<br />
<br />
LDAPSharedCacheSize 200000<br />
LDAPCacheEntries 1024<br />
LDAPCacheTTL 600<br />
LDAPOpCacheEntries 1024<br />
LDAPOpCacheTTL 600<br />
<br />
<Location /ldap-status><br />
<span class="indent">
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
AuthLDAPEnabled on<br />
AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one<br />
AuthLDAPAuthoritative on<br />
require valid-user<br />
</span>
</Location>
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="pool" id="pool">LDAP连接池</a></h2>
<p>LDAP连接是在请求之间共享的。这就允许LDAP服务器在跳过unbind->connect->rebind这样一个工作周期的情况下,保留连接以减少为下一次请求准备连接的时间。这种性能优化有点象HTTP服务的Keep-Alives功能。</p>
<p>在一个比较繁忙的服务器上,很有可能许多请求同时尝试与同一个LDAP服务进行连接并得到它的服务。如果一个LDAP连接正在使用,Apache会在原来连接的基础上,生成一个新的连接。这将确保连接池不会成为瓶颈。</p>
<p>不需要在Apache配置中手动开启连接池功能。任何使用本模块来访问LDAP服务的模块会自动共享连接池。</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="cache" id="cache">LDAP缓冲</a></h2>
<p>为了改善性能,<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>模块使用一种积极的缓冲策略以尽量减少与LDAP服务器的联系。通过缓冲,可以方便地使Apache在提供受mod_authnz_ldap保护的页面时,得到二倍或三倍的吞吐量。同时,LDAP服务器的负载也会明显地减小。</p>
<p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>支持两种类型的LDAP缓冲。在search/bind阶段,使用一个<em>search/bind缓冲</em>,在compare阶段,使用两个<em>operation缓冲</em>。服务器引用的每个LDAP URL都有一组它自己的上述三个缓冲。</p>
<h3><a name="search-bind" id="search-bind">Search/Bind缓冲</a></h3>
<p>处理一个查询和绑定操作对LDAP实施来讲,是非常耗时,尤其当目录很大时,这一点更加明显。Search/bind缓冲用来缓冲所有的最终能成功绑定的查询。失败的结果(比如:不成功的查询或查询结果无法成功绑定)不会被缓冲。这样做是因为信任关系失败的连接在所有连接中只占了很小的一个百分比,因此,通过不缓冲这些连接,可以减少缓冲区的大小。</p>
<p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>在缓冲区里储存了用户名、得到的DN 、用来绑定的口令、绑定的时间。当一个新的连接用同一个用户名来初始化的时候,<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>将新的连接的口令与保存在缓冲区里的口令进行比较。如果口令匹配,并且那个缓冲项目尚未失效的话,<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>就跳过search/bind阶段。</p>
<p>查询与绑定缓冲由<code class="directive"><a href="#ldapcacheentries">LDAPCacheEntries</a></code>和<code class="directive"><a href="#ldapcachettl">LDAPCacheTTL</a></code>指令来控制。</p>
<h3><a name="opcaches" id="opcaches">Operation缓冲</a></h3>
<p>在区分与辨别过程中,<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>使用两个操作缓冲区来缓冲比较的操作。第一个缓冲区用来缓冲是否LDAP组成员的测试结果,第二个用来缓冲不同名字间鉴别的比较结果。</p>
<p>这两个缓冲区都是由<code class="directive"><a href="#ldapopcacheentries">LDAPOpCacheEntries</a></code>和<code class="directive"><a href="#ldapopcachettl">LDAPOpCacheTTL</a></code>指令来控制的。</p>
<h3><a name="monitoring" id="monitoring">缓冲区的监控</a></h3>
<p><code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>包含了一个完整的处理器,通过它可以使管理员监控缓冲区的性能。这个处理器的名字是<code>ldap-status</code> ,因此可以用下列指令来得到<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>缓冲区的相关信息:</p>
<div class="example"><p><code>
<Location /server/cache-info><br />
<span class="indent">
SetHandler ldap-status<br />
</span>
</Location>
</code></p></div>
<p>通过URL <code>http://servername/cache-info</code> ,管理员可以得到<code class="module"><a href="../mod/mod_ldap.html">mod_ldap</a></code>使用的每个缓冲的状态报告。注意,如果Apache不支持共享内存,那么每个<code class="program"><a href="../programs/httpd.html">httpd</a></code>实例都有它自己的缓冲区,因此,每次使用上述URL都可能会得到不同的结果,这取决于具体哪个<code class="program"><a href="../programs/httpd.html">httpd</a></code>实例处理了这个请求。</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="usingssltls" id="usingssltls">使用SSL/TSL</a></h2>
<p>通过<code class="directive"><a href="#ldaptrustedglobalcert">LDAPTrustedGlobalCert</a></code>, <code class="directive"><a href="#ldaptrustedclientcert">LDAPTrustedClientCert</a></code>, <code class="directive"><a href="#ldaptrustedmode">LDAPTrustedMode</a></code>指令可以定义与LDAP服务器建立SSL/TSL联接。这些指令指定了使用的CA和可选的客户端证书,以及连接使用的加密类型(none, SSL, TLS/STARTTLS)。</p>
<div class="example"><p><code>
# 在636端口建立一个SSL LDAP联接。需要模块mod_ldap和mod_authnz_ldap的支持。<br />
# 将"yourdomain.example.com"修改为您自己的域名。<br />
<br />
LDAPTrustedGlobalCert CA_DER /certs/certfile.der<br />
<br />
<Location /ldap-status><br />
<span class="indent">
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
AuthLDAPEnabled on<br />
AuthLDAPURL ldaps://127.0.0.1/dc=example,dc=com?uid?one<br />
AuthLDAPAuthoritative on<br />
require valid-user<br />
</span>
</Location>
</code></p></div>
<div class="example"><p><code>
# 在389端口建立一个TLS LDAP联接。需要模块mod_ldap和mod_authnz_ldap的支持。<br />
# 将"yourdomain.example.com"修改为您自己的域名。<br />
<br />
LDAPTrustedGlobalCert CA_DER /certs/certfile.der<br />
<br />
<Location /ldap-status><br />
<span class="indent">
SetHandler ldap-status<br />
Order deny,allow<br />
Deny from all<br />
Allow from yourdomain.example.com<br />
AuthLDAPEnabled on<br />
LDAPTrustedMode TLS
AuthLDAPURL ldap://127.0.0.1/dc=example,dc=com?uid?one<br />
AuthLDAPAuthoritative on<br />
require valid-user<br />
</span>
</Location>
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="settingcerts" id="settingcerts">SSL/TLS Certificates</a></h2>
<p>The different LDAP SDKs have widely different methods of setting
and handling both CA and client side certificates.</p>
<p>If you intend to use SSL or TLS, read this section CAREFULLY so as to
understand the differences between configurations on the different LDAP
toolkits supported.</p>
<h3><a name="settingcerts-netscape" id="settingcerts-netscape">Netscape/Mozilla/iPlanet SDK</a></h3>
<p>CA certificates are specified within a file called cert7.db.
The SDK will not talk to any LDAP server whose certificate was
not signed by a CA specified in this file. If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -