Skip to content

Instantly share code, notes, and snippets.

@SunDi3yansyah
Last active September 8, 2023 15:10
Show Gist options
  • Save SunDi3yansyah/b885b4c0ebf2e46a4f2fde4faf34cb4b to your computer and use it in GitHub Desktop.
Save SunDi3yansyah/b885b4c0ebf2e46a4f2fde4faf34cb4b to your computer and use it in GitHub Desktop.
Cara Install Secure Nginx dengan Let's Encrypt di CentOS 7

Step 1 — Installing the Certbot Let's Encrypt Client

sudo yum install epel-release
sudo yum install certbot-nginx

Step 2 — Setting up Nginx

sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Disini kamu konfigurasi Nginx-nya terlebih dahulu, beserta set server_name domain mana aja yang ingin di SSL kan dan ini adalah konfigurasi masih menggunakan port 80 atau posisi belum terset SSL nya.

Kalau sudah

sudo systemctl reload nginx

Step 3 — Updating the Firewall

Setting Firewall ke open port 80 dan 443 => https://git.io/fx6GU

Step 4 — Obtaining a Certificate

sudo certbot --nginx -d example.com -d www.example.com

Ikuti intruksinya

Step 5 — Updating Diffie-Hellman Parameters

sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
sudo vi /etc/nginx/nginx.conf

Update, dan masukan ini kedalam block server

ssl_dhparam /etc/ssl/certs/dhparam.pem;
sudo nginx -t
sudo systemctl reload nginx

Step 6 — Setting Up Auto Renewal

sudo crontab -e
@monthly sudo /usr/bin/certbot renew --quiet

Restart Crond Service

sudo systemctl restart crond.service

Step 7 — Expand Domain Certificate

sudo certbot --expand -d new-domain.com
@SunDi3yansyah
Copy link
Author

sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment