How To Securely Manage Secrets with HashiCorp Vault on Ubuntu 16.04


Let’s Encrypt is a Certificate Authority (CA) that delivers an way that is easy obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the process that is entire of and setting up a certificate is completely automatic on both Apache and Nginx.

In this guide, you’ll utilize Certbot to acquire a totally free SSL certification for Nginx on Ubuntu 16.04 and set your certificate up to restore immediately.

This guide use a nginx that is separate block file instead of the default file. We recommend creating Nginx that is new server files for every domain since it helps avoid some traditional errors and keeps the standard files as a fallback setup as meant. You can follow this Nginx + Let’s Encrypt tutorial instead.( if you want to set up SSL using the default server block,*******)


To follow this guide, you will require:

  • One Ubuntu 16.04 host setup by third server that is initial for Ubuntu 16.04 guide, including a sudo non-root individual and a firewall.

  • A completely registered domain title. This guide shall utilize throughout. You can buy a domain title on Namecheap, get one 100% free on Freenom, or make use of the domain registrar of the option.

  • Both of after DNS documents setup for the host. This hostname can be followed by you guide for information on how exactly to include them.

    • An an archive with pointing towards host’s general public ip.
    • An an archive with pointing towards host’s general public ip.
  • Nginx set up by after just how to Install Nginx on Ubuntu 16.04.

  • A split Nginx host block declare your domain, setup by third Nginx host obstructs tutorial for Ubuntu 16.04. This guide use /etc/nginx/sites-available/

Step 1 — Installing Certbot

The first rung on the ladder to utilizing let us Encrypt to acquire an SSL certification is always to install the Certbot computer software on your own host.

Certbot is in really development that is active so that the Certbot packages supplied by Ubuntu are outdated. But the Certbot designers keep a Ubuntu computer software repository with up-to-date variations, therefore we are going to utilize that repository as an alternative.

First, include the repository.

  • sudo add-apt-repository ppa:certbot/certbot

Youwill need to press ENTER to simply accept. Then, upgrade the package list to grab the repository that is new package information.

And finally, install Certbot's Nginx package with apt-get.

  • sudo apt-get install python-certbot-nginx

Certbot happens to be prepared to utilize, however in purchase we need to verify some of Nginx's configuration.( for it to configure SSL for Nginx,*******)

Step 2 — Confirming Nginx's Configuration

Certbot has to manage to find the proper server block within Nginx setup because of it to automatically be able to configure SSL. Especially, it will this by in search of a server_name directive that fits the domain you request a certificate for.

(you should have a server block for your domain at /etc/nginx/sites-available/ with the server_name directive already set appropriately.

If you followed the prerequisite tutorial on Nginx server blocks,*******)

To check, start the host block declare your domain utilizing nano or your preferred text editor.

  • sudo nano***************) that is/etc/nginx/sites-available/(****************)

Find the present server_name line. It will appear to be this:


. . .
. . .

(you can exit your editor and move on to the next step.

If it does,*******)

(it to match******)If it doesn't, update. Then conserve the file, stop your editor, and validate the syntax of the setup edits.

If you will get a mistake, reopen the host block file and search for any typos or characters that are missing. Once your configuration file's syntax is correct, reload Nginx to load the configuration that is new

  • sudo systemctl reload nginx

Certbot are now able to find the proper server block and upgrade it.

Next, we are going to upgrade our firewall to permit HTTPS traffic.

Step 3 — enabling HTTPS through Firewall

If you've got the ufw firewall enabled, as suggested by the guides that are prerequisite you'll need to adjust the settings to allow for HTTPS traffic. Luckily, Nginx registers a profiles that are few ufw upon installation.

You can easily see the setting that is current typing:

It will appear to be this, and therefore just traffic that is HTTP permitted to the net host:


Status: active To Action From -- ------ ---- OpenSSH ENABLE Anywhere Nginx HTTP ENABLE Anywhere OpenSSH (v6) ENABLE Anywhere (v6) Nginx(v6 that are HTTP ENABLE Anywhere (v6)

To also allow in HTTPS traffic, we could let the Nginx Comprehensive profile and delete the redundant then Nginx HTTP profile allowance:

  • sudo ufw enable 'Nginx Comprehensive'
  • sudo ufw allow that is delete HTTP'

Your status should appear to be this now:


Status: active To Action From -- ------ ---- OpenSSH ENABLE Anywhere Nginx Complete ENABLE Anywhere OpenSSH (v6) ENABLE Anywhere (v6) Nginx(v6 that are full ENABLE Anywhere (v6)

We're now prepared to run Certbot and fetch our certificates.

Step 4 — acquiring an SSL Certificate

Certbot provides a number of methods to get SSL certificates, through different plugins. The Nginx plugin takes care of reconfiguring Nginx and reloading the config whenever ( that is necessary*******)

  • sudo certbot --nginx -d -d

This operates certbot using the --nginx plugin, utilizing -d to specify the names we want the certification become legitimate for.

If this really is your time that is first running*************)certbot, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot will communicate with the Let's Encrypt server, run a challenge then to validate which you control the domain you are asking for a certificate for.

If that is effective, certbot will ask the method that you'd always configure your HTTPS settings.


Please choose if to redirect HTTP traffic to HTTPS, getting rid of access that is HTTP. ------------------------------------------------------------------------------- 1: No redirect - Make no changes that are further the webserver setup. 2: Redirect - Make all demands redirect to secure HTTPS access. Select this for brand new websites, or you're confident your website works on HTTPS. You are able to undo our modification by modifying your online host's setup. ------------------------------------------------------------------------------- Choose the number that is appropriate*) then [enter] (press 'c' to cancel):

Select your decision then hit ENTER. The setup may be updated, and Nginx will reload to grab the settings that are new. certbot will summary with an email letting you know the method ended up being effective and in which your certificates are saved:


IMPORTANT NOTES: - Congratulations! Your chain and certificate have now been conserved at /etc/letsencrypt/live/ Your cert shall expire on 2017-10-23. To have a brand new or version that is tweaked of certification later on, just again run certbot using the "certonly" choice. To non-interactively restore *all* of the certificates, operate "certbot renew" - Your account qualifications have now been conserved within Certbot setup directory at /etc/letsencrypt. You need to make a protected back-up of the folder now. This setup directory shall additionally have certificates and keys that are private by Certbot so making regular backups of the folder is perfect. - if you prefer Certbot, please contemplate supporting our work by: Donating to ISRG / let us Encrypt: Donating to EFF:

Your certificates are installed, set up, and packed. Take to reloading your internet site utilizing https:// and notice your web browser's protection indicator. It will suggest your website is correctly guaranteed, frequently with a lock icon that is green. It will get an A grade.( if you test your server using the SSL Labs Server Test,*******)

Let's finish by testing the renewal procedure.

Step 5 — Verifying Certbot Auto-Renewal

Let's Encrypt's certificates are just legitimate for three months. This is certainly to encourage users to automate their renewal that is certificate process. The certbot package we installed takes care of this for us by adding a renew script to /etc/cron.d. This script runs twice a and will automatically renew any certificate that's within thirty days of expiration.( day*******)

To test the renewal procedure, you are able to do a run that is dry certbot:

  • sudo certbot renew --dry-run

If the thing is no mistakes, you are prepared. Whenever necessary, Certbot will restore your certificates and reload Nginx to choose the changes up. If the renewal that is automated ever fails, Let’s Encrypt will be sending an email to your e-mail you specified, warning you as soon as your certification is mostly about to expire.


In this guide, you installed the let us Encrypt customer certbot, installed SSL certificates for the domain, configured Nginx to utilize these certificates, and setup certificate renewal that is automatic. If you have further questions about using Certbot, their documentation is a place that is good begin.

An instrument for Viewing Git Repositories in Linux Terminal

Previous article

Linux nm Command Tutorial for newbies (10 Examples)

Next article

You may also like


Leave a Reply

More in Apache