Linux – Internal Server Error 500 Apache 2.4 with LDAP authentication on CentOs 7

apache-2.4ldaplinux

I have a centos 7 server with apache 2.4.6 and enabled mod_ldap and mod_authnz_ldap modules. After entering username and password I get Internal server 500 error and not showing any error logs in error.log file.
Here is the configuration file

    <VirtualHost *:443>
    ServerName mypage.local
    ServerAlias www.mypage.local
    DocumentRoot /var/www/html/mycompany
    SSLEngine on
    SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
    SSLCertificateFile /etc/pki/tls/certs/server.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/server.key
    ErrorLog /var/log/httpd/error.log
    </VirtualHost>

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{HTTPS} !on
     RewriteRule .* https://%{HTTP_HOST}/%{REQUEST_URI} [R=301,L,QSA]
     </IfModule>
     <Location />

     SSLRequireSSL
     #LDAPTrustedGlobalCert CA_BASE64 /etc/pki/tls/certs/server.crt
     #LDAPTrustedMode TLS
     AuthType Basic
     AuthName "Akhil"
     AuthBasicProvider ldap
     #LDAPVerifyServerCert  off
     AuthLDAPBindDN "cn=read-only,dc=example,dc=com"
     AuthLDAPBindPassword "password"
     AuthLDAPURL "ldap://xxxxxxx.com:389/ou=xxxxx,dc=example,dc=com?sAMAccountName?sub?(ObjectClass=*)"
     #AuthUserFile /var/www/html/mycompany/htpasswd
     Require valid-user
     </Location>

The authentication works perfectly with htpasswd and got internal server error with AuthBasicProvider as ldap.
I've also attached the error log.. Used self signed certificate for https….

[Sat Jan 07 16:08:23.216525 2017] [ssl:warn] [pid 3815] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name
[Sat Jan 07 16:08:23.274161 2017] [ssl:warn] [pid 3815] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name
[Sat Jan 07 16:27:15.571289 2017] [ssl:warn] [pid 3982] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name
[Sat Jan 07 16:27:15.627542 2017] [ssl:warn] [pid 3982] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name
[Sat Jan 07 16:28:40.799204 2017] [ssl:warn] [pid 4017] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name
[Sat Jan 07 16:28:40.854610 2017] [ssl:warn] [pid 4017] AH01909: RSA certificate configured for mypage.local:443 does NOT include an ID which matches the server name

Best Answer

Can you try the following three changes?

  1. SSLRequireSSL removed
  2. valid-user changed to ldap-user
  3. START_TLS re-enforced (see AuthLDAPURL)

, require

# the following two directives have to be OUTSIDE vhost
LDAPTrustedGlobalCert CA_BASE64 /etc/pki/tls/certs/server.crt
LDAPTrustedMode TLS
<VirtualHost *:443>
[...]
<Location />
 AuthType Basic
 AuthName "Akhil"
 AuthBasicProvider ldap
 AuthLDAPBindDN "cn=read-only,dc=example,dc=com"
 AuthLDAPBindPassword "password"
 # note TLS added at the end of this line
 AuthLDAPURL "ldap://xxxxxxx.com:389/ou=xxxxx,dc=example,dc=com?sAMAccountName?sub?(ObjectClass=*)" TLS
 #AuthUserFile /var/www/html/mycompany/htpasswd
 Require ldap-user
</Location>