Install Let’s Encrypt on Debian/Ubuntu with Nginx

posted in: Uncategorized | 0

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   git is not installed then execute the following command:

Generate an SSL Certificate

  • Navigate to /opt/letsencrypt:
  • Run Let’s Encrypt with the --standalone parameter. For multiple domains add -d
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  /etc/letsencrypt/live/ The two files that are need are fullchain.pem and privkey.pem.

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  /etc/nginx/sites-available/default, 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, Let's Encrypt Authority X3, 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

  • If OCSP stapling is enabled, in the OCSP Response Data section, it should say the following:

Renewing SSL Certificates

Go to:

Then enter:

It will show a similar message below, certificates have a 90-day lifespan before they expire:


Install Let’s Encrypt to Create SSL Certificates

How To Secure Nginx with Let’s Encrypt on Ubuntu 14.04

Setting up OCSP stapling for Let’s Encrypt certificates under nginx