GNU/Linux >> Belajar Linux >  >> Cent OS

Cara Memasang Sertifikat SSL Gratis untuk Nginx di CentOS 8

Dalam tutorial ini, kami akan menunjukkan cara menginstal Sertifikat SSL gratis untuk Nginx di CentOS 8. Bagi Anda yang belum tahu, Let's Encrypt adalah otoritas sertifikat terbuka gratis ( CA) yang menyediakan sertifikat gratis untuk situs web dan layanan lainnya. Layanan ini didukung oleh Electronic Frontier Foundation, Mozilla, Cisco Systems, dan Akamai.

Artikel ini mengasumsikan Anda memiliki setidaknya pengetahuan dasar tentang Linux, tahu cara menggunakan shell, dan yang terpenting, Anda meng-host situs Anda di VPS Anda sendiri. Instalasi cukup sederhana dan mengasumsikan Anda sedang berjalan di akun root, jika tidak, Anda mungkin perlu menambahkan 'sudo ' ke perintah untuk mendapatkan hak akses root. Saya akan menunjukkan kepada Anda melalui langkah-demi-langkah instalasi Sertifikat SSL Gratis untuk Nginx di server CentOS 8.

Prasyarat

  • Server yang menjalankan salah satu sistem operasi berikut:CentOS 8.
  • Sebaiknya Anda menggunakan penginstalan OS baru untuk mencegah potensi masalah.
  • Seorang non-root sudo user atau akses ke root user . Kami merekomendasikan untuk bertindak sebagai non-root sudo user , namun, karena Anda dapat membahayakan sistem jika tidak berhati-hati saat bertindak sebagai root.

Instal Sertifikat SSL Gratis untuk Nginx di CentOS 8

Langkah 1. Pertama, mari kita mulai dengan memastikan sistem Anda mutakhir.

dnf update

Langkah 2. Menginstal Certbot di CentOS 8.

Jalankan perintah ini pada baris perintah pada mesin untuk menginstal Certbot:

wget https://dl.eff.org/certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
sudo chown root /usr/local/bin/certbot-auto
sudo chmod 0755 /usr/local/bin/certbot-auto

Kemudian, jalankan perintah ini untuk mendapatkan sertifikat dan minta Certbot mengedit konfigurasi Nginx Anda secara otomatis:

sudo /usr/local/bin/certbot-auto --nginx

Hasilnya seperti di bawah ini:

Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: your-domain-a.com
2: your-domain-b.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for your-domain-a.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/your-domain-a.com.conf

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
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/your-domain-a.com.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://your-domain-a.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=your-domain-a.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/your-domain-a.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/your-domain-a.com/privkey.pem
   Your cert will expire on 2020-01-12. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto 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

Langkah 3. Certbot Auto-Renew Cron Job.

Ayo Enkripsi sertifikat SSL yang akan kedaluwarsa setelah 90 hari penginstalan dan Anda harus memperbaruinya sebelum kedaluwarsa. Jika Anda telah menginstal sertifikat menggunakan Certbot maka harus memiliki sudah membuat tugas cron untuk memperbarui sertifikat secara otomatis:

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew" | sudo tee -a /etc/crontab > /dev/null

Selamat! Anda telah berhasil menginstal Sertifikat SSL gratis. Terima kasih telah menggunakan tutorial ini untuk menginstal Let's Encrypt SSL Certificates pada sistem CentOS 8. Untuk bantuan tambahan atau informasi berguna, kami sarankan Anda memeriksa Let's Official Enkripsi situs web.


Cent OS
  1. Cara Memasang Sertifikat SSL di NGINX

  2. Cara Menginstal Sertifikat SSL di Apache untuk CentOS 7

  3. SSL gratis untuk Nginx di Centos oleh Let's encrypt

  1. Cara menginstal ssl di RHEL 8 / CentOS 8

  2. Cara Menginstal Nginx di CentOS 7

  3. Cara Menginstal Nginx di CentOS 8

  1. Cara Memasang Sertifikat SSL di CentOS 7

  2. Cara Menginstal Magento 2.1 di CentOS 7

  3. Cara Menginstal Restyaboard di CentOS 7