Saya kebetulan diminta untuk explore mengenai open ldap, kali ini saya akan coba share hasil instalasi OpenLDAP dan phpLDAPadmin di Ubuntu 14.04 Server. Sekalian saja saya tulis di blog ini sebagai catatan saya juga.
Sebelum nya saya sudah pernah bahas sedikit tentang LDAP disini. Dan saat ini adalah prakteknya, yaitu cara install nya. Berikut langkah instalasi ldap nya :
1. Install dulu ldap nya :
$ sudo apt-get update
$ sudo apt-get install slapd ldap-utils
2. Setelah selsai installnya, di reconfigure dulu ldap nya agar mendapatkan konfigurasi terbaik :
$ sudo dpkg-reconfigure slapd
Nanti akan muncul beberapa wizard pertanyaan seperti dibawah ini :
- Omit OpenLDAP server configuration? No
- DNS domain name?
- This option will determine the base structure of your directory path. Read the message to understand exactly how this will be implemented.
- This is actually a rather open option. You can select whatever "domain name" value you'd like, even if you don't own the actual domain. However, if you have a domain name for the server, it's probably wise to use that.
- For this guide, we're going to select test.com for our configuration.
- Organization name?
- This is, again, pretty much entirely up to your preferences.
- For this guide, we will be using example as the name of our organization.
- Administrator password?
- As I mentioned in the installation section, this is your real opportunity to select an administrator password. Anything you select here will overwrite the previous password you used.
- Database backend? HDB
- Remove the database when slapd is purged? No
- Move old database? Yes
- Allow LDAPv2 protocol? No
Install phpLDAPadmin untuk Manage LDAP via Web Interface
Cara nya adalah :
1. Install dulu phpLDAPadmin nya
$ sudo apt-get install phpldapadmin
2. Setelah selesai install, lakukan konfigurasi nya :
$ sudo nano /etc/phpldapadmin/config.php
Cari parameter ini :
$servers->setValue('server','host','server_domain_name_or_IP');
Dan di sesuaikan IP server ubuntu nya.
Masih di file yang sama, cari lagi parameter ini, dan ganti nama domain nya, misal nya saya menggunakan domain test.com, maka hasil nya mejadi :
$servers->setValue('server','base',array('dc=test,dc=com'));
Lalu masih di file yang sama lagi, cari parameter dibawah ini dan di ganti menjadi seperti ini :
$servers->setValue('login','bind_id','cn=admin,dc=test,dc=com');
Lalu masih di file yang sama lagi, cari parameter dibawah ini dan di ganti menjadi seperti ini :
$config->custom->appearance['hide_template_warning'] = true;
setelah selesai simpan perubahan file nya
Membuat Sertifikat SSL agar phpLDAPadmin lebih secure
Caranya :
1. Buat Folder nya dulu :
$ sudo mkdir /etc/apache2/ssl
2. Generate SSL nya :
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
Install Apache (Web Server) dan Create Password Authentication File nya
Cara nya adalah :
1. Install apache nya dulu :
$ sudo apt-get install apache2-utils
2. Buat user di apache nya (nama user nya demo_user) :
$ sudo htpasswd -c /etc/apache2/htpasswd demo_user
Membuat Apache nya Lebih Secure
Langkah pertama adalah mengaktifkan ssl module apache nya
$ sudo a2enmod ssl
Modifikasi phpLDAPadmin pada Konfigurasi Apache nya
Caranya adalah :
1. Edif file konfigurasi nya :
$ sudo nano /etc/phpldapadmin/apache.conf
2. Pada file apache.conf nya edit pada bagian ini menjadi seperti ini :
IfModule mod_alias.c
Alias /superldap /usr/share/phpldapadmin/htdocs
/IfModule
setelah selesai simpan perubahan file nya
Konfigurasi virtual host di apache nya
Caranya adalah :
1. Edit file konfig apache nya :
sudo nano /etc/apache2/sites-enabled/000-default.conf
Cari parameter ini :
VirtualHost *:80
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
/VirtualHost
Buat menjadi seperti ini contohnya :
VirtualHost *:80
ServerAdmin webmaster@server_domain_or_IP
DocumentRoot /var/www/html
ServerName server_domain_or_IP
Redirect permanent /superldap https://server_domain_or_IP/superldap
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
/VirtualHost
Nama domain di sesuaikan, misal menjadi test.com, setelah selesai simpan perubahan file nya
Configure HTTPS di Virtual Host Apache nya
Cara nya adalah :
1. Edit file ssl apache nya :
$ sudo a2ensite default-ssl.conf
$ sudo nano /etc/apache2/sites-enabled/default-ssl.conf
Rubah parameter dibawah ini dan sesuaikan dengan domain yang digunakan, misal nya test.com
ServerAdmin webmaster@server_domain_or_IP
ServerName server_domain_or_IP
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Location /superldap
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/htpasswd
Require valid-user
/Location
/Location
2. Setelah selesai, simpan perubahan file nya dan restart service apache nya :
$ sudo service apache2 restart
Selesai, sekarang tinggal coba login saja ke phpLDAPadmin dari web browser :
http://server_domain_name_or_IP/superldap
Jika muncul error seperti ini di lanjutkan saja, itu error karena ssl nya generate sendiri, dan bukan beli ssl yang berbayar :
Lalu akan muncul halaman login :
Klik "login" pada menu di samping kiri, dan login ke dalam ldap nya :
Setelah berhasil login ke dalam ldap nya, maka akan muncul tampilan seperti ini :
Selesai, Kita tinggal manage ldap nya dari web inteface nya phpLDAPadmin. Nanti kalau sempat akan saya bahas juga cara manage ldap nya
Semoga bermanfaat juga untuk teman semua.
Dony Ramansyah
site : http://donyramansyah.net
blog : dony-ramansyah.blogspot.com
email : dony.ramansyah[at]gmail.com
Registered linux user : ID 40017
Tidak ada komentar:
Posting Komentar