Membangun aplikasi web di era modern memerlukan pondasi yang kokoh. Framework modern memberikan fleksibilitas luar biasa bagi developer untuk menghadirkan fitur kompleks secara cepat tanpa mengabaikan aspek keamanan dan keandalan sistem.
Tahapan Implementasi & Walkthrough Kode
Berikut adalah langkah demi langkah teknis yang dapat Anda ikuti langsung pada codebase Anda:
Tahap 1: Penulisan Kode & Konfigurasi
sudo add-apt-repository ppa:certbot/certbot
Tahap 2: Penulisan Kode & Konfigurasi
sudo apt-get update
Tahap 3: Penulisan Kode & Konfigurasi
sudo apt-get install python-certbot-nginx
Tahap 4: Penulisan Kode & Konfigurasi
sudo nano /etc/nginx/sites-available/default
Tahap 5: Penulisan Kode & Konfigurasi
. . .
server_name example.com www.example.com;
. . .
Tahap 6: Penulisan Kode & Konfigurasi
sudo nginx -t
Tahap 7: Penulisan Kode & Konfigurasi
sudo systemctl reload nginx
Tahap 8: Penulisan Kode & Konfigurasi
sudo ufw status
Tahap 9: Penulisan Kode & Konfigurasi
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
Tahap 10: Penulisan Kode & Konfigurasi
sudo ufw allow 'Nginx Full'
Tahap 11: Penulisan Kode & Konfigurasi
sudo ufw delete allow 'Nginx HTTP'
Tahap 12: Penulisan Kode & Konfigurasi
sudo ufw status
Tahap 13: Penulisan Kode & Konfigurasi
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
Tahap 14: Penulisan Kode & Konfigurasi
sudo certbot --nginx -d example.com -d www.example.com
Tahap 15: Penulisan Kode & Konfigurasi
sudo certbot --nginx -d example.com -d www.example.com -d santrikoding.com -d www.santrikoding.com
Tahap 16: Penulisan Kode & Konfigurasi
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):
Tahap 17: Penulisan Kode & Konfigurasi
Output
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/example.com/fullchain.pem. Your cert will
expire on 2017-10-23. 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
Tahap 18: Penulisan Kode & Konfigurasi
sudo certbot renew --dry-run
Selalu gunakan pendekatan deklaratif, validasi input seawal mungkin di boundary layer, dan lakukan logging terstruktur untuk memudahkan observability ketika sistem dijalankan di lingkungan cloud produksi.
Kesimpulan
Dengan mengikuti langkah-langkah terstruktur di atas, implementasi modul Anda akan jauh lebih rapi, aman dari bug umum, serta siap diskalakan ke lingkungan produksi.
Nantikan artikel tutorial praktis lainnya seputar fullstack development, microservices, dan otomasi AI di Blog Engineering SiHubung. Selamat mencoba!