Digitalocean Letsencrypt Nginx Ubuntu 18.04

Digitalocean Letsencrypt Nginx Ubuntu 18.04


Ubuntu 18.04 is the latest version of the popular Linux operating system. Digitalocean is a cloud hosting provider that specializes in hosting and managing web applications. As part of its hosting services, Digitalocean offers Let’s Encrypt SSL certificates. Let’s Encrypt is a free certificate authority that allows webmasters and website owners to quickly and easily create secure web sites. Let’s Encrypt certificates are used to identify websites as part of the secure communication protocol known as SSL/TLS. Nginx is an open source web server that can be used to serve static web content or proxy requests to another server. In this tutorial, we’ll show you how to install and configure Digitalocean Let’s Encrypt SSL on ubuntu 18.04 with Nginx web server.


Before you start with this tutorial, make sure that you have the following:

  • A Digitalocean account with access to the Digitalocean console.
  • An Ubuntu 18.04 server, installed on a virtual server (droplet) with a public IP address.
  • A working Nginx web server with Ubuntu 18.04.
  • A valid domain name, with a DNS record pointing to the server’s public IP address.

Once you have all of the prerequisites in place, you can proceed with this tutorial.

Step 1 – Install Nginx and Certbot

The first step is to install Nginx and the Certbot client. To do this, first connect to your server via SSH and update the server software. Run the following commands:

sudo apt-get update
sudo apt-get install nginx
sudo apt-get install certbot

Once the installations are finished, you can proceed to the next step.

Step 2 – Generate the SSL Certificate

Now that Nginx and Certbot are installed, you can generate and install your SSL certificate. To do this, first create a directory for the SSL certificate files:

sudo mkdir /etc/nginx/ssl

Then generate the SSL certificate:

sudo certbot --nginx -d

Replace with the name of your domain.

If you are not asked for a validation method, you will be asked to enter a valid email address. Enter your email address and continue. Next, you will be asked if you want to receive emails about renewing your certificate. Select “Yes” and continue.

Step 3 – Configure Nginx

Once you have generated the SSL certificate, it’s time to configure Nginx to use the certificate. To do this, first navigate to the /etc/nginx/sites-enabled directory:

cd /etc/nginx/sites-enabled

In this directory, you will find the default Nginx configuration file called “default”. Open this file in your favorite text editor:

sudo nano default

Add the following lines to the file:

server {
listen 80;
return 301 https://$server_name$request_uri;

server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/;
ssl_certificate_key /etc/nginx/ssl/;
# Add your website configuration here...

Replace with the name of your domain. Then save and close the file.

Step 4 – Restart Nginx

Once your Nginx configuration is updated, restart the Nginx web server. To do this, run the following command:

sudo service nginx restart


In this tutorial, we have shown you how to install and configure Digitalocean Let’s Encrypt SSL certificates on Ubuntu 18.04 with Nginx web server. We have also showed you how to configure Nginx to use the generated SSL certificate. We hope you have found this tutorial useful and that you are now more confident about setting up secure websites with Digitalocean’s Let’s Encrypt SSL certificates.

Frequently Asked Questions

Q: Does Digitalocean provide Let’s Encrypt for free?

A: Yes, Digitalocean provides Let’s Encrypt certificates at no cost to its users.

Q: Is Nginx necessary for Let’s Encrypt?

A: Yes, you will need to have Nginx installed and configured before generating the Let’s Encrypt certificate.

Q: How often do I need to renew my Let’s Encrypt certificate?

A: Let’s Encrypt certificates are valid for three months. You will need to renew your certificate every three months to keep your website secure.

Thank you for reading this article. For more information on Digitalocean Let’s Encrypt, please refer to our How To Secure Nginx with Let’s Encrypt on Ubuntu 18.04 tutorial. For more information on Digitalocean tutorials, please see our Digitalocean tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *