Mastering Let's Encrypt for Your Web Server: A Practical Configuration Guide
Configuring the free SSL provider for your HTTP server is now a standard practice for any webmaster. This guide outlines the key procedures to set up a valid certificate using the official ACME client.
Prerequisites and Initial Setup
Before starting the configuration, confirm your server has a reachable domain pointing to it. You will need sudo privileges and a HTTP daemon like Apache. The Certbot package must be set up via your apt or yum. For example, on Debian, run: `sudo apt install certbot` or `sudo yum install certbot`.
Obtaining the Certificate
The simplest method is to use the webroot plugin. For Nginx, the `--apache` or `--nginx` plugin can seamlessly modify your server block. Run: here `sudo certbot --apache -d example.com -d www.example.com`. This triggers the domain validation. If you prefer the webroot approach, use: `sudo certbot certonly --webroot -w /var/www/html -d example.com`. This creates a token in your public folder.
Web Server Configuration Adjustments
After downloading the certificate, you must modify your server block to reference the correct paths. For Nginx, the typical directives are:
- SSLCertificateFile: `/etc/letsencrypt/live/example.com/fullchain.pem`
- ssl_certificate_key: `/etc/letsencrypt/live/example.com/privkey.pem`
Ensure you activate HTTPS rewriting from HTTP to HTTPS. A 301 redirect is recommended. For Nginx, include a `return 301 https://$host$request_uri;` or use `RewriteEngine On` with `RewriteRule`.
Automated Renewal and Verification
Let's Encrypt certificates are valid for 90 days. The client configures a systemd timer to refresh them without manual intervention. To simulate the renewal process, run: `sudo certbot renew --dry-run`. Check your server logs for warnings. If the renewal fails, troubleshoot for port 80 issues.
Security Hardening (Optional but Recommended)
To enhance security, enable STS headers by adding `add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;` in your virtual host. Also, disable SSLv3 and use modern ciphers. A robust configuration secures your visitors from downgrade attacks.
By following these guidelines, your site will be protected with a free Let's Encrypt certificate, guaranteeing trust for every connection.