GNU/Linux >> Tutoriales Linux >  >> Cent OS

Cómo instalar un certificado SSL gratuito para Nginx en CentOS 8

En este tutorial, le mostraremos cómo instalar un certificado SSL gratuito para Nginx en CentOS 8. Para aquellos de ustedes que no lo sabían, Let's Encrypt es una autoridad de certificación abierta y gratuita ( CA) que proporciona certificados gratuitos para sitios web y otros servicios. El servicio está respaldado por Electronic Frontier Foundation, Mozilla, Cisco Systems y Akamai.

Este artículo asume que tiene al menos conocimientos básicos de Linux, sabe cómo usar el shell y, lo que es más importante, aloja su sitio en su propio VPS. La instalación es bastante simple y asume que se están ejecutando en la cuenta raíz, si no, es posible que deba agregar 'sudo ' a los comandos para obtener privilegios de root. Le mostraré paso a paso la instalación del Certificado SSL gratuito para Nginx en el servidor CentOS 8.

Requisitos previos

  • Un servidor que ejecuta uno de los siguientes sistemas operativos:CentOS 8.
  • Se recomienda que utilice una instalación de sistema operativo nueva para evitar posibles problemas.
  • Un non-root sudo user o acceder al root user . Recomendamos actuar como un non-root sudo user , sin embargo, puede dañar su sistema si no tiene cuidado al actuar como root.

Instalar certificado SSL gratuito para Nginx en CentOS 8

Paso 1. Primero, comencemos asegurándonos de que su sistema esté actualizado.

dnf update

Paso 2. Instalación de Certbot en CentOS 8.

Ejecute estos comandos en la línea de comandos de la máquina para instalar 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

Luego, ejecute este comando para obtener un certificado y hacer que Certbot edite su configuración de Nginx automáticamente:

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

El resultado es el siguiente:

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

Paso 3. Trabajo cron de renovación automática de Certbot.

Los certificados Let's Encrypt SSL que caducan después de 90 días de la instalación y debe renovarlos antes de que caduquen. Si ha instalado certificados usando Certbot, entonces debe tener ya creó un trabajo cron para renovar automáticamente los certificados:

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

¡Felicitaciones! Ha instalado correctamente los certificados SSL gratuitos. Gracias por usar este tutorial para instalar los certificados SSL de Let's Encrypt en el sistema CentOS 8. Para obtener ayuda adicional o información útil, le recomendamos que consulte el sitio web oficial Let's Cifrar sitio web.


Cent OS
  1. Cómo instalar un certificado SSL en NGINX

  2. Cómo instalar un certificado SSL en Apache para CentOS 7

  3. Cómo instalar ssl en RHEL 8 / CentOS 8

  4. Cómo instalar Nginx en CentOS 7

  5. SSL gratis para Nginx en Centos por Let's encrypt

Cómo instalar Wetty en CentOS 7

Cómo instalar LetsEncrypt SSL con Nginx en CentOS 6

Cómo instalar Let's Encrypt SSL con Nginx en CentOS 7

Cómo instalar un certificado SSL gratuito para Apache en CentOS 8

Cómo instalar Varnish Cache 6 para Nginx en CentOS/RHEL 8

¿Cómo instalar Nginx en CentOS 7?