This post combines several different sources of information on installing Let’s Encrypt on Debian/Ubuntu and configuring SSL on nginx and will show how to install Let’s Encrypt on Ubuntu with nginx already installed. As of writing there is no automated install process provided by Let’s Encrypt for nginx.
For more detailed information see the sources at the end of this post.
Before You Begin
- Make sure the server has at least 2GB of RAM. If not, add or increase your swap size to meet this requirement, otherwise problems may occur during install as reported here and here.
- Update the server software packages:
Clone and Install Let’s Encrypt
- If is not installed then execute the following command:
- Clone the Let’s Encrypt GitHub repository to :
Generate an SSL Certificate
- Navigate to :
- Run Let’s Encrypt with the parameter. For multiple domains add :
From: Sudo Manual
- Next enter an administrative email address and follow the prompts:
- Agree to the Terms of Service:
- If no problems occur then a similar message will show below:
- The files that will be used in nginx for the certificate are located at . The two files that are need are and .
Generate Strong Diffie-Hellman Group
- To increase security, generate a strong Diffie-Hellman group. To generate a 2048-bit group, use this command:
- This will take a while to generate.
Configure SSL in Nginx
- Edit the nginx configuration that contains your server block. The default one is located at , for the purpose this post we will edit this one:
- Now locate the following lines and comment out or remove them in your server block:
- The following is an example configuration:
OCSP Stapling for Let’s Encrypt Certificate with Nginx
- Determine which of the Let’s Encrypt certificates was used to sign your certificate:
- The output will be similar to the following:
- That last part, , is the name of the Let’s Encrypt certificate that was used to sign the certificate.
- Download the PEM version of this certificate. All of the Let’s Encrypt intermediate certificates are on the Let’s Encrypt site; click on the “PEM” link for the appropriate certificate to get the file you need. Or, from the command line,
- Replace “x3” with a different certificate name if necessary.
- Edit the nginx configuration from before and add:
Apply the Changes
- Test the nginx configuration:
- Reload nginx to put the changes into effect:
Test the SSL Certificate
- Check with the DigiCert SSL Installation Diagnostic Tool at: https://www.digicert.com/help/
- Check with Qualys SSL Labs Report to see how your server configuration scores at: https://www.ssllabs.com/ssltest/analyze.html (should result in a A+ rating, it will show “OCSP stapling: No” here is the explaination of why)
- By command line:
- If OCSP stapling is enabled, in the OCSP Response Data section, it should say the following:
Renewing SSL Certificates
It will show a similar message below, certificates have a 90-day lifespan before they expire: