Artikel ini saya akan membahas tentang cara kita bagaimana install atau pasang SSL di Nginx menggunakan Let’s Enrcrypt, karena belakangan ini saya beberapa kali melakukan installasi SSL menggunakan Let’s Enrcypt entah itu Nginx maupun Apache dan juga entah itu di ubuntu atau Centos server.
Hal hal yang perlu di perhatikan sebelum install SSL di Nginx :
- Pastikan subdomain yang akan di generate SSL sudah resolved A recordnya.
- Saya sarankan untuk menggunakan metode virtual host / conf di nginx create sendiri , silahkan klik link berikut ini.
Cara Install SSL menggunakan Let’s Encrypt di Nginx :
Step 1 – Install CertBot
Install Certbot dan nginx plugin :
$ sudo apt install certbot python3-certbot-nginx
Step 2 – Configuration Nginx VHost
- Lakukan pengecekan pada configuration cond kita di file
.conf
$ sudo nano /etc/nginx/sites-available/example.com
- Pastikan server_namenya benar subdomain / domain yang digunakan, jika lebih dari 1 domain tinggal tambahkan dengan spasi.
... server_name example.com www.example.com; ...
- Testing nginx apakah ada error atau tidak
$ sudo nginx -t
- Reload nginx
$ sudo systemctl reload nginx
Step 3 – Obatining an SSL Certificate
- Gunakan syntax plugin certbot dan tambahkan domain yang sudah kalian input di
.confnginx tadi
$ sudo certbot --nginx -d example.com -d www.example.com atau $ sudo certbot --nginx
Certbotadalah syntax plugin--nginxweb server yang digunakan dan-dspesifikasi nama domain yang ada di.conffile nginx kita.
Output 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): Enter
- Jika proses yang berjalan diatas sudah selesai maka akan ada notif seperti dibawah ini dan tandanya SSL berhasil terinstall di domain kita.
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 2020-08-18. 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" - 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
Step 5 – Memverifikasi Perpanjangan Otomatis Certbot
- Lakukan query status di certbot timer
$ sudo systemctl status certbot.timer
output
● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Mon 2020-05-04 20:04:36 UTC; 2 weeks 1 days ago
Trigger: Thu 2020-05-21 05:22:32 UTC; 9h left
Triggers: ● certbot.service
- Renewal cerbot
$ sudo certbot renew --dry-run
Demikian artikel kali ini, selamat mencoba.

Admin website igunawan.com, System Administrator, DevOps Engineer

oke mantap pak,