Panduan cara install SSL di localhost Linux Ubuntu agar bisa diakses melalui protokol HTTPS. Akses Terminal, selanjutnya jalankan perintah berikut:
Catatan: pakai user sudo jangan pakai root!
Install libnss3-tools dan golang
cd; sudo apt install libnss3-tools golang git -y;cd /usr/share
Install mkcert
git clone https://github.com/FiloSottile/mkcert && cd mkcert go build -ldflags "-X main.Version=$(git describe --tags)" ln -s /sr/share/mkcert/mkcert /usr/bin/mkcert; cd
Instal SSL di localhost
Install CAROOT
mkcert -install
Contoh install sertifikat untuk localhost atau hosts
mkcert localhost 127.0.0.1 sesuatu.local *.sesuatu.local
Atau bisa juga dengan opsi menamai file sertifikat dan key sesuai keinginan
mkcert -key-file omar.key.pem -cert-file omar.cert.pem omar.md *.omar.md
Hasilnya kalau berhasil
omar@ubuntu:~$ mkcert -key-file omar.key.pem -cert-file omar.cert.pem omar.md *.omar.md Using the local CA at "/home/omar/.local/share/mkcert" ✨ Created a new certificate valid for the following names 📜 - "omar.md" - "*.omar.md" Reminder: X.509 wildcards only go one level deep, so this won't match a.b.omar.md ℹ️ The certificate is at "omar.cert.pem" and the key at "omar.key.pem" ✅
Selanjutnya pindahnya file .pem
ke /etc/nginx/ssl
atau /etc/apache2/ssl
Jika pakai Apache
sudo mkdir /etc/apache2/ssl;sudo mv *.pem /etc/apache2/ssl/
Jika pakai Nginx
sudo mkdir /etc/nginx/ssl;sudo mv *.pem /etc/nginx/ssl/
Tinggal konfigurasi ke Nginx/Apache, jangan lupa restart web server ya.
Screenshot
Mudah bukan? Semoga bermanfaat.