DEV Community

Cover image for Nginx: How to create an SSL Self-Signed Certificate on Ubuntu
Ousseynou Diop
Ousseynou Diop

Posted on • Updated on • Originally published at ousseynoudiop.com

Nginx: How to create an SSL Self-Signed Certificate on Ubuntu

Originally posted on my blog

Introduction

In this tutorial I will help you to create an SSL certificate, using Nginx and Certbot on Ubuntu.

SSL Certificates protect your sensitive information such as credit card information, usernames, passwords...

Nginx is a free, open-source, high-performance HTTP server.

Certbot is a free, open-source software tool for automatically using Let’s Encrypt certificates on manually-administrated websites to enable HTTPS.

Requirements

Nginx
Ubuntu
Comfort with command Line/Terminal

Installation

1- Login To Your Server


$ ssh username@YOUR_SERVER_IP

Enter fullscreen mode Exit fullscreen mode

2- Add Certbot PPA


$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update

Enter fullscreen mode Exit fullscreen mode

3- Install Certbot

$ sudo apt-get install certbot python-certbot-nginx
Enter fullscreen mode Exit fullscreen mode

4- Generate the certificate

$ sudo certbot --nginx
Enter fullscreen mode Exit fullscreen mode

Choose your domaine


[sudo] password for username:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: yourdomaine.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Enter fullscreen mode Exit fullscreen mode

Choose whether or not to redirect HTTP traffic to HTTPS.

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Enter fullscreen mode Exit fullscreen mode

Successfully issued

Congratulations! You have successfully enabled https://yourdomaine.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=yourdomaine.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/yourdomaine.com-0001/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/yourdomaine.com-0001/privkey.pem
   Your cert will expire on 2020-04-14. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Enter fullscreen mode Exit fullscreen mode

5- Test automatic renewal

$ sudo certbot renew --dry-run
Enter fullscreen mode Exit fullscreen mode

Thanks for reading.
See you in the next tutorial

Top comments (1)

Collapse
 
itsignacioportal profile image
Ignacio J. Perez Portal

WRONG: Certbot does not create self-signed certificates. certbot uses Let's Encrypt.