Apache2 : Basic Authentication + LDAP2021/09/07 |
Configure [mod_ldap] to use LDAP directory users on httpd Basic authentication.
On this example, it uses Active Directory like following environment for it.
|
|||||||||||
[1] |
Username and password are sent with plain text on Basic Authentication,
so Use secure connection with SSL/TLS setting, refer to here.
|
||||||||||
[2] |
Create a user on Active Directory for binding Active Directory from httpd.
On this example, it creates [ldapuser], it's OK to grant [Domain Users] rights only for it. |
||||||||||
[3] | Configure Basic authentication + LDAP. For example, set Basic Authentication to the directory [/var/www/html/auth-ldap]. |
root@www:~#
vi /etc/apache2/sites-available/auth_ldap.conf # create new # on example below, it limits the range to search the directory only [LDAPUsers] OU # so only users under the [LDAPUsers] OU can authenticate with this setting # for [AuthLDAPBindDN] and [AuthLDAPBindPassword], specify the AD user for binding <Directory "/var/www/html/auth-ldap"> SSLRequireSSL AuthType Basic AuthName "LDAP Authentication" AuthBasicProvider ldap AuthLDAPURL "ldap://fd3s.srv.world:389/ou=LDAPUsers,dc=srv,dc=world?sAMAccountName?sub?(objectClass=*)" AuthLDAPBindDN ldapuser@srv.world AuthLDAPBindPassword Password Require valid-user </Directory>
root@www:~#
root@www:~# chgrp www-data /etc/apache2/sites-available/auth_ldap.conf root@www:~# chmod 640 /etc/apache2/sites-available/auth_ldap.conf
a2enmod ldap authnz_ldap Enabling module ldap. Enabling module authnz_ldap. To activate the new configuration, you need to run: systemctl restart apache2root@www:~# a2ensite auth_ldap Enabling site auth_ldap. To activate the new configuration, you need to run: systemctl reload apache2
root@www:~#
systemctl restart apache2 # create a test page root@www:~# mkdir /var/www/html/auth-ldap root@www:~# vi /var/www/html/auth-ldap/index.html <html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Test Page for LDAP Authentication </div> </body> </html> |
[4] | Access to the test page from any client computer with web browser. Then authentication is required as settings, answer with any AD user. |
[5] | That's OK if authentication is successfully passed and test page is displayed normally. |
Sponsored Link |
|