Dalam tutorial ini kita akan menggunakan sertifikat ssl gratis yang disediakan oleh Lets Encrypt untuk membuat situs web aman dengan mengaktifkan HTTPS. Kami akan menginstal sertifikat yang disediakan oleh memungkinkan mengenkripsi menggunakan klien certbot EFF.
Langkah-langkah untuk Menginstal Sertifikat SSL Gratis Let's Encrypt
- Prasyarat
- Aktifkan HTTPS untuk Google Cloud VM
- SSH Google Cloud VM
- Cadangkan File Konfigurasi Apache
- Instal Klien Certbot
- Instal Sertifikat dengan Certbot untuk Apache
- Uji Koneksi HTTPS
- Perpanjangan Otomatis Sertifikat.
1. Prasyarat
Sebelum melanjutkan dengan tutorial ini, kami berasumsi bahwa Anda telah berhasil mengatur situs web di google cloud dan situs web dapat diakses melalui domain. Kami juga berasumsi bahwa Anda dapat ssh cloud vm Anda baik dari browser web menggunakan google cloud console atau dengan mengonfigurasi koneksi ssh berbasis kunci publik dari mesin lokal.
2. Aktifkan HTTPS untuk Google Cloud VM
Buka Google Compute Engine Instance dan Pilih Edit untuk mengaktifkan HTTPSlalu lintas.

Ini akan membuat aturan firewall untuk membuka port 443pada instance komputasi dan memfasilitasi penyajian permintaan HTTPS setelah pemasangan sertifikat.
3. SSH Google Cloud VM
SSH ke cloud vm dari mesin lokal Anda.
techmonger@ubuntu:~$ ssh 93.184.216.34
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
techmonger@google-vm:~$
4. Cadangkan File Konfigurasi Apache
Sebelum melanjutkan dengan instalasi sertifikat, penting untuk memiliki cadangan file konfigurasi Webserver yang ada. Program penginstalan sertifikat akan mengubah file konfigurasi selama penginstalan sertifikat . Mencadangkan file konfigurasi yang ada akan memberi kita kesempatan untuk mengembalikan konfigurasi lama kembali jika ada yang tidak berfungsi seperti yang diharapkan setelah instalasi sertifikat.
$ mkdir /tmp/apache_config_backup/
$ cp -r /etc/apache2/* /tmp/apache_config_backup/
5. Instal Klien Certbot
Kami telah membuat instance VM dengan Debian OS dan akan menggunakan perintah berikut untuk menginstal klien certbot. Namun jika Anda memiliki beberapa OS lain untuk VM Anda, silakan ikuti instruksi di https://certbot.eff.orguntuk menginstal certbot.
$ sudo apt-get install python-certbot-apache -t stretch-backports
6. Instal Sertifikat dengan Certbot untuk Apache
Memulai Program Instalasi Sertifikat
$ sudo certbot --authenticator webroot --installer apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer apache
Berikan Alamat Email yang valid
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): techmonger@example.com
Terima (A) Mari Mengenkripsi Syarat dan Ketentuan
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
Opsi untuk Berbagi Email dengan EFF. Pilih (Y/T) tergantung pada preferensi Anda.
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 our work
encrypting the web, EFF news, campaigns, and ways to
support digital freedom.
(Y)es/(N)o: Y
Nama domain untuk menginstal sertifikat. (example.com)
No names were found in your configuration files.
Please enter in your domain name(s) (comma and/or space separated)
(Enter 'c' to cancel): example.com
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Root Server Web tempat konten situs web disimpan dan dapat diakses. ( /var/www/html)
Input the webroot for example.com:
(Enter 'c' to cancel): /var/www/html
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at
/etc/apache2/sites-available/000-default-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost
/etc/apache2/sites-available/000-default-le-ssl.conf
Enabling available site:
/etc/apache2/sites-available/000-default-le-ssl.conf
Opsi Untuk mengkonfigurasi HTTPuntuk HTTPS mengarahkan ulang. Pilih 1 atau 2 tergantung pada apakah Anda ingin mengonfigurasi pengalihan atau tidak.
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): 2
Enabled Apache rewrite module
Redirecting vhost in
/etc/apache2/sites-enabled/000-default.conf to ssl vhost in
/etc/apache2/sites-available/000-default-le-ssl.conf
-----------------------------------------------------
Pesan untuk Konfigurasi yang Berhasil
Congratulations! You have successfully enabled https:/example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
Detail tentang file sertifikat
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2018-09-10. 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.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF:https://eff.org/donate-le
7. Uji Koneksi HTTPS
Buka domain situs web di browser web dengan HTTPSdan pastikan situs web berfungsi seperti yang diharapkan. Jika redirect dikonfigurasi, maka periksa HTTPuntuk HTTPSmengarahkan ulang halaman situs web dengan membuka halaman dengan HTTPdi browser.
8. Perpanjangan Otomatis Sertifikat.
Secara default, sertifikat mari mengenkripsi akan kedaluwarsa setelah 90 hari penginstalan. Penting untuk memiliki cara otomatis untuk memperbarui sertifikat sebelum tanggal kedaluwarsa. Certbot melakukan ini untuk Anda dengan membuat tugas cron. Pelajari lebih lanjut tentang cara kerja sertifikat perpanjangan otomatis certbot.
Kesimpulan
Kami telah menginstal Lets encrypt SSL certificates gratis untuk situs web statis yang dihosting di google cloud vm. Sertifikat ini telah dikonfigurasi untuk server web Apache menggunakan klien Certbot. Kami juga telah menyiapkan perpanjangan otomatis sertifikat untuk menghindari perpanjangan manual dan kedaluwarsa sertifikat.