GNU/Linux >> Znalost Linux >  >> Cent OS

Jak nainstalovat bezplatný certifikát SSL pro Nginx na CentOS 8

V tomto tutoriálu vám ukážeme, jak nainstalovat bezplatný certifikát SSL pro Nginx na CentOS 8. Pro ty z vás, kteří nevěděli, Let's Encrypt je bezplatná otevřená certifikační autorita ( CA), která poskytuje bezplatné certifikáty pro webové stránky a další služby. Službu podporují Electronic Frontier Foundation, Mozilla, Cisco Systems a Akamai.

Tento článek předpokládá, že máte alespoň základní znalosti Linuxu, víte, jak používat shell, a co je nejdůležitější, hostujete svůj web na svém vlastním VPS. Instalace je poměrně jednoduchá a předpokládá, že běží v účtu root, pokud ne, možná budete muset přidat 'sudo ‘ k příkazům pro získání oprávnění root. Ukážu vám krok za krokem instalaci bezplatného certifikátu SSL pro Nginx na serveru CentOS 8.

Předpoklady

  • Server s jedním z následujících operačních systémů:CentOS 8.
  • Abyste předešli případným problémům, doporučujeme použít novou instalaci operačního systému.
  • non-root sudo user nebo přístup k root user . Doporučujeme jednat jako non-root sudo user , protože však můžete poškodit svůj systém, pokud nebudete při jednání jako root opatrní.

Nainstalujte bezplatný certifikát SSL pro Nginx na CentOS 8

Krok 1. Nejprve začněme tím, že zajistíme, aby byl váš systém aktuální.

dnf update

Krok 2. Instalace Certbota na CentOS 8.

Spuštěním těchto příkazů na příkazovém řádku na počítači nainstalujte 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

Potom spusťte tento příkaz, abyste získali certifikát a Certbot automaticky upravil vaši konfiguraci Nginx:

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

Výsledek je následující:

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

Krok 3. Certbot Auto-Renew Cron Job.

Let's Encrypt SSL certifikáty, kterým vyprší platnost po 90 dnech od instalace a musíte je obnovit, než vyprší. Pokud jste nainstalovali certifikáty pomocí Certbota, musí mít již vytvořil úlohu cron pro automatické obnovení certifikátů:

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

Blahopřejeme! Úspěšně jste nainstalovali bezplatné certifikáty SSL. Děkujeme, že jste použili tento návod k instalaci certifikátů Let's Encrypt SSL v systému CentOS 8. Další nápovědu nebo užitečné informace získáte na oficiálních stránkách Let's Šifrovat web.


Cent OS
  1. Jak nainstalovat certifikát SSL na NGINX

  2. Jak nainstalovat certifikát SSL na Apache pro CentOS 7

  3. Zdarma SSL pro Nginx na Centos od Let’s encrypt

  1. Jak nainstalovat ssl na RHEL 8 / CentOS 8

  2. Jak nainstalovat Nginx na CentOS 7

  3. Jak nainstalovat Nginx na CentOS 8

  1. Jak nainstalovat certifikát SSL na CentOS 7

  2. Jak nainstalovat Magento 2.1 na CentOS 7

  3. Jak nainstalovat Restyaboard na CentOS 7