Cara Install Lets Encrypt di Linux

Assalamualaikum Warrahmatullahi Wabarakatuh

Halo gan, pada artikel kali ini saya akan coba membahas mengenai bagaimana cara melakukan Instalasi Lets Encrypt di Linux. Let’s Encrypt adalah sebuah service yang menyediakan Certificate SSL secara GRATIS alias tidak berbayar. Dengan adanya SSL Free seperti ini, kita bisa membuat website kita diakses menggunakan https tanpa harus membayar certificate SSL.

Oke langsung saja kita ke prakteknya. Dalam praktek kali ini saya akan mencoba untuk menggunakan https pada subdomain webmail saya yaitu webmail.cindy-yuvia.org.  Sebelum menggunakan https, koneksi webmail saya akan tampak seperti dibawah ini

Tampilannya masih menunjukkan not secure dan tidak ada https nya. Nanti kita akan buat tampilannya berubah menjadi https. Berikut adalah langkah-langkahnya.

1. Anggap saja httpd, php, sql dam seperangkat kebutuhan web nya sudah berjalan dengan baik.

2. Install Repo EPEL. Karena paket-paket yang dibutuhkan ada di repository tersebut:
# yum install epel-release

3. Install Mod SSL dan Certbot (aplikasi untuk Lets Encrypt).
# yum install mod_ssl python-certbot-apache

4. Request install SSL untuk subdomain webmail.cindy-yuvia.org.
# certbot –apache -d webmail.cindy-yuvia.org

5. Nanti akan ada beberapa pilihan dibawah ini:
——————————————
Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to
cancel): sabto@cindy-yuvia.org

Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v01.api.letsencrypt.org/directory
(A)gree/(C)ancel: A

Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let’s Encrypt project and the non-profit organization that develops Certbot? We’d like to send you email about EFF andour work to encrypt the web, protect its users and defend digital rights.
(Y)es/(N)o: N

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
1: No redirect – Make no further changes to the webserver configuration.
2: Redirect – Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you’re confident your site works on HTTPS. You can undo this change by editing your web server’s configuration.
Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel): 1

IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/webmail.cindy-yuvia.org/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/webmail.cindy-yuvia.org/privkey.pem
Your cert will expire on 2018-07-25. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the “certonly” option. To non-interactively renew *all* of your certificates, run “certbot renew”
– Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal.
———————————————————-
Mohon untuk di Copy-Paste yang bagian terakhir (start from IMPORTANT NOTES). Karena info ini berisi summary dari hasil instalasi dan juga ada cara untuk renew certificate nya.

6. Edit ssl.conf dan beri tanda # pada dua baris berikut.
# nano /etc/httpd/conf.d/ssl.conf
————————————-
# SSLProtocol all -SSLv2
# SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
————————————–

7. Masih di file yang sama, masukan baris dibawah ini setelah baris </VirtualHost>
————————————–
# from https://cipherli.st/
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_Apache2.html

SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder On
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the “preload” directive if you understand the implications.
#Header always set Strict-Transport-Security “max-age=63072000; includeSubdomains; preload”
Header always set Strict-Transport-Security “max-age=63072000; includeSubdomains”
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
# Requires Apache >= 2.4
SSLCompression off
SSLUseStapling on
SSLStaplingCache “shmcb:logs/stapling-cache(150000)”
# Requires Apache >= 2.4.11
# SSLSessionTickets Off
————————————–

8. Sebenarnya akan ada file VirtualHost yang akan Terbentuk ketika proses di no 4. File VirtualHost itu berisi konfigurasi untuk https nya. Isinya kurang lebih sebagai berikut:
# nano /etc/httpd/sites-available/webmail-le-ssl.conf
—————————————-
<IfModule mod_ssl.c>
<VirtualHost 31.220.22.26:443>
ServerName webmail.cindy-yuvia.org
DocumentRoot /var/www/html/webmail/
ErrorLog /var/www/html/errorwebmail.log
CustomLog /var/www/html/requestwebmail.log combined
SSLCertificateFile /etc/letsencrypt/live/webmail.cindy-yuvia.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/webmail.cindy-yuvia.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/webmail.cindy-yuvia.org/chain.pem
</VirtualHost>
</IfModule>
—————————————–
Jika sudah ada anda bisa abaikan saja dan lanjut ke tahap berikut.

9. Buat redirection dari http ke https dengan cara mengedit file VirtualHost dari subdomain tersebut dan tambahkan baris berikut:
# nano /etc/httpd/sites-available/webmail.conf
—————————————-
<VirtualHost 31.220.22.26:80>
ServerName webmail.cindy-yuvia.org
DocumentRoot /var/www/html/webmail/
ErrorLog /var/www/html/errorwebmail.log
CustomLog /var/www/html/requestwebmail.log combined
Redirect permanent / https://webmail.cindy-yuvia.org
</VirtualHost>
—————————————-

10. Restart Apache nya
# service httpd restart

11. Setelah itu coba kembali untuk mengakses webmail.cindy-yuvia.com. Maka seharusnya akan otomatis teredirect ke https://webmail.cindy-yuvia.org.

Sekian artikel mengenai Lets Encrypt dan jangan lupa untuk Share artikel supaya bermanfaat untuk banyak orang. Jika yang ingin berdiskusi silahkan comment di artikel ini. 🙂

Wassalamualaikum Warrahmatullahi Wabarakatuh

Ref: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-centos-7

Leave a Reply

Your email address will not be published. Required fields are marked *