Бесплатный SSL сертификат:
Here's a step-by-step guide to installing an SSL certificate from Let's Encrypt for your server, assuming you're using Nginx as your web server:
Step 1: Install CertbotCertbot is the official Let's Encrypt client used to manage certificates:
bashapt update
apt install certbot python3-certbot-nginx -y
Step 2: Run CertbotCertbot can automatically handle both the certificate acquisition and Nginx configuration for you. Run the following command:
Replace
yourdomain.com with your actual domain name. If you only have one domain, you can omit the -d
www.yourdomain.com part.Certbot will ask for an email address for urgent renewal and security notices and whether you want to share your email with the EFF (Electronic Frontier Foundation).
Step 3: Follow Certbot PromptsCertbot will:Ask for your email address.Ask if you agree to the terms of service.Ask to share your email address with the EFF.Ask if you want to redirect all traffic from HTTP to HTTPS. This is generally recommended for security.
Step 4: Verify InstallationAfter Certbot runs:
It will modify your Nginx configuration to use the new SSL certificate.You should see a message confirming the installation and possibly a test URL to verify your certificate.
Step 5: Test Your HTTPS ConnectionOpen a browser and go to
https://yourdomain.com to check if the site loads securely.You can also use an SSL checker tool like SSL Labs to verify your certificate.
Step 6: Automatic RenewalCertbot sets up a cron job to automatically check and renew certificates. However, you can manually check the renewal status or force a manual renewal with:
bashcertbot renew --dry-run # Dry run to test renewal process
Additional Notes:Permissions: Ensure that Certbot has the necessary permissions to modify your Nginx configuration files. If you're using root or have sudo privileges, this should not be an issue.Firewall: Make sure your firewall allows traffic on port 443 (HTTPS). If using UFW:
bashufw allow 'Nginx HTTPS'Redirect HTTP to HTTPS: If Certbot didn't set up an HTTP to HTTPS redirect, or if you want to do it manually, you can add this to your Nginx server block:
nginxserver {
listen 80;
return 301 https://$host$request_uri;
}
And then reload Nginx:
bashsystemctl reload nginxTroubleshooting: If you encounter issues, check Certbot's logs:
bashtail -f /var/log/letsencrypt/letsencrypt.logMultiple Domains/Subdomains: If you need certificates for multiple domains or subdomains, include them all with -d flags in your Certbot command.
By following these steps, you should have an SSL certificate installed for your domain from Let's Encrypt, ensuring your site is served securely over HTTPS.