Раздел 10. Apache modules Пункты: 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 RU EN Пункт 157. Apache Module mod_ldap
SummaryThis module was created to improve the performance of websites relying on backend connections to LDAP servers. In addition to the functions provided by the standard LDAP libraries, this module adds an LDAP connection pool and an LDAP shared memory cache. To enable this module, LDAP support must be compiled into
apr-util. This is achieved by adding the SSL/TLS support is dependent on which LDAP toolkit has been linked to APR. As of this writing, APR-util supports: OpenLDAP SDK (2.x or later), Novell LDAP SDK, Mozilla LDAP SDK, native Solaris LDAP SDK (Mozilla based) or the native Microsoft LDAP SDK. See the APR website for details. Example ConfigurationThe following is an example configuration that uses
# Enable the LDAP connection pool and shared # memory cache. Enable the LDAP cache status # handler. Requires that mod_ldap and mod_authnz_ldap # be loaded. Change the "yourdomain.example.com" to # match your domain. LDAPSharedCacheSize 500000 LDAPCacheEntries 1024 LDAPCacheTTL 600 LDAPOpCacheEntries 1024 LDAPOpCacheTTL 600 <Location "/ldap-status"> SetHandler ldap-status Require host yourdomain.example.com Satisfy any AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=com?uid?one" Require valid-user </Location> LDAP Connection PoolLDAP connections are pooled from request to request. This allows the LDAP server to remain connected and bound ready for the next request, without the need to unbind/connect/rebind. The performance advantages are similar to the effect of HTTP keepalives. On a busy server it is possible that many requests will try and access the same LDAP server connection simultaneously. Where an LDAP connection is in use, Apache will create a new connection alongside the original one. This ensures that the connection pool does not become a bottleneck. There is no need to manually enable connection pooling in the Apache configuration. Any module using this module for access to LDAP services will share the connection pool. LDAP connections can keep track of the ldap client
credentials used when binding to an LDAP server. These
credentials can be provided to LDAP servers that do not
allow anonymous binds during referral chasing. To control
this feature, see the
LDAP CacheFor improved performance, The Search/Bind CacheThe process of doing a search and then a bind is the most time-consuming aspect of LDAP operation, especially if the directory is large. The search/bind cache is used to cache all searches that resulted in successful binds. Negative results (i.e., unsuccessful searches, or searches that did not result in a successful bind) are not cached. The rationale behind this decision is that connections with invalid credentials are only a tiny percentage of the total number of connections, so by not caching invalid credentials, the size of the cache is reduced. The search and bind cache is controlled with the Operation CachesDuring attribute and distinguished name comparison
functions, Note that, when group membership is being checked, any sub-group comparison results are cached to speed future sub-group comparisons. The behavior of both of these caches is controlled with
the Monitoring the Cache <Location "/server/cache-info"> SetHandler ldap-status </Location> By fetching the URL Using SSL/TLSThe ability to create an SSL and TLS connections to an LDAP server
is defined by the directives
# Establish an SSL LDAP connection on port 636. Requires that # mod_ldap and mod_authnz_ldap be loaded. Change the # "yourdomain.example.com" to match your domain. LDAPTrustedGlobalCert CA_DER "/certs/certfile.der" <Location "/ldap-status"> SetHandler ldap-status Require host yourdomain.example.com Satisfy any AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one" Require valid-user </Location> # Establish a TLS LDAP connection on port 389. Requires that # mod_ldap and mod_authnz_ldap be loaded. Change the # "yourdomain.example.com" to match your domain. LDAPTrustedGlobalCert CA_DER "/certs/certfile.der" <Location "/ldap-status"> SetHandler ldap-status Require host yourdomain.example.com Satisfy any AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=com?uid?one" TLS Require valid-user </Location> SSL/TLS CertificatesThe different LDAP SDKs have widely different methods of setting and handling both CA and client side certificates. 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. Netscape/Mozilla/iPlanet SDKCA 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 client certificates are required, an optional key3.db file may be specified with an optional password. The secmod file can be specified if required. These files are in the same format as used by the Netscape Communicator or Mozilla web browsers. The easiest way to obtain these files is to grab them from your browser installation. Client certificates are specified per connection using the LDAPTrustedClientCert directive by referring to the certificate "nickname". An optional password may be specified to unlock the certificate's private key. The SDK supports SSL only. An attempt to use STARTTLS will cause an error when an attempt is made to contact the LDAP server at runtime. # Specify a Netscape CA certificate file LDAPTrustedGlobalCert CA_CERT7_DB "/certs/cert7.db" # Specify an optional key3.db file for client certificate support LDAPTrustedGlobalCert CERT_KEY3_DB "/certs/key3.db" # Specify the secmod file if required LDAPTrustedGlobalCert CA_SECMOD "/certs/secmod" <Location "/ldap-status"> SetHandler ldap-status Require host yourdomain.example.com Satisfy any AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap LDAPTrustedClientCert CERT_NICKNAME <nickname> [password] AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one" Require valid-user </Location> Novell SDKOne or more CA certificates must be specified for the Novell SDK to work correctly. These certificates can be specified as binary DER or Base64 (PEM) encoded files. Note: Client certificates are specified globally rather than per connection, and so must be specified with the LDAPTrustedGlobalCert directive as below. Trying to set client certificates via the LDAPTrustedClientCert directive will cause an error to be logged when an attempt is made to connect to the LDAP server.. The SDK supports both SSL and STARTTLS, set using the LDAPTrustedMode parameter. If an ldaps:// URL is specified, SSL mode is forced, override this directive. # Specify two CA certificate files LDAPTrustedGlobalCert CA_DER "/certs/cacert1.der" LDAPTrustedGlobalCert CA_BASE64 "/certs/cacert2.pem" # Specify a client certificate file and key LDAPTrustedGlobalCert CERT_BASE64 "/certs/cert1.pem" LDAPTrustedGlobalCert KEY_BASE64 "/certs/key1.pem" [password] # Do not use this directive, as it will throw an error #LDAPTrustedClientCert CERT_BASE64 "/certs/cert1.pem" OpenLDAP SDKOne or more CA certificates must be specified for the OpenLDAP SDK to work correctly. These certificates can be specified as binary DER or Base64 (PEM) encoded files. Both CA and client certificates may be specified globally (LDAPTrustedGlobalCert) or per-connection (LDAPTrustedClientCert). When any settings are specified per-connection, the global settings are superseded. The documentation for the SDK claims to support both SSL and STARTTLS, however STARTTLS does not seem to work on all versions of the SDK. The SSL/TLS mode can be set using the LDAPTrustedMode parameter. If an ldaps:// URL is specified, SSL mode is forced. The OpenLDAP documentation notes that SSL (ldaps://) support has been deprecated to be replaced with TLS, although the SSL functionality still works. # Specify two CA certificate files LDAPTrustedGlobalCert CA_DER "/certs/cacert1.der" LDAPTrustedGlobalCert CA_BASE64 "/certs/cacert2.pem" <Location "/ldap-status"> SetHandler ldap-status Require host yourdomain.example.com LDAPTrustedClientCert CERT_BASE64 "/certs/cert1.pem" LDAPTrustedClientCert KEY_BASE64 "/certs/key1.pem" # CA certs respecified due to per-directory client certs LDAPTrustedClientCert CA_DER "/certs/cacert1.der" LDAPTrustedClientCert CA_BASE64 "/certs/cacert2.pem" Satisfy any AuthType Basic AuthName "LDAP Protected" AuthBasicProvider ldap AuthLDAPURL "ldaps://127.0.0.1/dc=example,dc=com?uid?one" Require valid-user </Location> Solaris SDKSSL/TLS for the native Solaris LDAP libraries is not yet supported. If required, install and use the OpenLDAP libraries instead. Microsoft SDKSSL/TLS certificate configuration for the native Microsoft LDAP libraries is done inside the system registry, and no configuration directives are required. Both SSL and TLS are supported by using the ldaps:// URL format, or by using the LDAPTrustedMode directive accordingly. Note: The status of support for client certificates is not yet known for this toolkit. LDAPCacheEntries Directive
Specifies the maximum size of the primary LDAP cache. This cache contains successful search/binds. Set it to 0 to turn off search/bind caching. The default size is 1024 cached searches. LDAPCacheTTL Directive
Specifies the time (in seconds) that an item in the search/bind cache remains valid. The default is 600 seconds (10 minutes). LDAPConnectionPoolTTL Directive
Specifies the maximum age, in seconds, that a pooled LDAP connection can remain idle and still be available for use. Connections are cleaned up when they are next needed, not asynchronously. A setting of 0 causes connections to never be saved in the backend connection pool. The default value of -1, and any other negative value, allows connections of any age to be reused. For performance reasons, the reference time used by this directive is based on when the LDAP connection is returned to the pool, not the time of the last successful I/O with the LDAP server. Since 2.4.10, new measures are in place to avoid the reference time from being inflated by cache hits or slow requests. First, the reference time is not updated if no backend LDAP conncetions were needed. Second, the reference time uses the time the HTTP request was received instead of the time the request is completed. This timeout defaults to units of seconds, but accepts suffixes for milliseconds (ms), minutes (min), and hours (h). LDAPConnectionTimeout Directive
This directive configures the LDAP_OPT_NETWORK_TIMEOUT (or LDAP_OPT_CONNECT_TIMEOUT) option in the underlying LDAP client library, when available. This value typically controls how long the LDAP client library will wait for the TCP connection to the LDAP server to complete. If a connection is not successful with the timeout period, either an error will be
returned or the LDAP client library will attempt to connect to a secondary LDAP
server if one is specified (via a space-separated list of hostnames in the
The default is 10 seconds, if the LDAP client library linked with the server supports the LDAP_OPT_NETWORK_TIMEOUT option. LDAPConnectionTimeout is only available when the LDAP client library linked with the server supports the LDAP_OPT_NETWORK_TIMEOUT (or LDAP_OPT_CONNECT_TIMEOUT) option, and the ultimate behavior is dictated entirely by the LDAP client library.LDAPLibraryDebug Directive
Turns on SDK-specific LDAP debug options that generally cause the LDAP SDK to log verbose trace information to the main Apache error log. The trace messages from the LDAP SDK provide gory details that can be useful during debugging of connectivity problems with backend LDAP servers This option is only configurable when Apache HTTP Server is linked with
an LDAP SDK that implements The logged information will likely contain plaintext credentials being used or validated by LDAP authentication, so care should be taken in protecting and purging the error log when this directive is used. LDAPOpCacheEntries Directive
This specifies the number of entries LDAPOpCacheTTL Directive
Specifies the time (in seconds) that entries in the operation cache remain valid. The default is 600 seconds. LDAPReferralHopLimit Directive
This directive, if enabled by the Support for this tunable is uncommon in LDAP SDKs. LDAPReferrals Directive
Some LDAP servers divide their directory among multiple domains and use referrals to direct a client when a domain boundary is crossed. This is similar to a HTTP redirect. LDAP client libraries may or may not chase referrals by default. This directive explicitly configures the referral chasing in the underlying SDK.
The directive LDAPRetries Directive
The server will retry failed LDAP requests up to
LDAP errors such as timeouts and refused connections are retryable. LDAPRetryDelay Directive
If LDAP errors such as timeouts and refused connections are retryable. LDAPSharedCacheFile Directive
Specifies the directory path and file name of the shared memory cache file. If not set, anonymous shared memory will be used if the platform supports it. LDAPSharedCacheSize Directive
Specifies the number of bytes to allocate for the shared memory cache. The default is 500kb. If set to 0, shared memory caching will not be used and every HTTPD process will create its own cache. LDAPTimeout Directive
This directive configures the timeout for bind and search operations, as well as the LDAP_OPT_TIMEOUT option in the underlying LDAP client library, when available. If the timeout expires, httpd will retry in case an existing connection has been silently dropped by a firewall. However, performance will be much better if the firewall is configured to send TCP RST packets instead of silently dropping packets. Timeouts for ldap compare operations requires an SDK with LDAP_OPT_TIMEOUT, such as OpenLDAP >= 2.4.4. LDAPTrustedClientCert Directive
It specifies the directory path, file name or nickname of a per connection client certificate used when establishing an SSL or TLS connection to an LDAP server. Different locations or directories may have their own independent client certificate settings. Some LDAP toolkits (notably Novell) do not support per connection client certificates, and will throw an error on LDAP server connection if you try to use this directive (Use the LDAPTrustedGlobalCert directive instead for Novell client certificates - See the SSL/TLS certificate guide above for details). The type specifies the kind of certificate parameter being set, depending on the LDAP toolkit being used. Supported types are:
LDAPTrustedGlobalCert Directive
It specifies the directory path and file name of the trusted CA
certificates and/or system wide client certificates
LDAPTrustedMode Directive
The following modes are supported:
Not all LDAP toolkits support all the above modes. An error message will be logged at runtime if a mode is not supported, and the connection to the LDAP server will fail. If an ldaps:// URL is specified, the mode becomes SSL and the setting of LDAPTrustedMode is ignored. LDAPVerifyServerCert Directive
Specifies whether to force the verification of a server certificate when establishing an SSL connection to the LDAP server. Пункты: 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 |