Secure Nginx with Let's Encrypt on Ubuntu 14.04

Step 1 — Installing Certbot
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
Step 2 — Setting up Nginx
sudo nano /etc/nginx/sites-available/default
   Find the existing server_name line:
/etc/nginx/sites-available/default
server_name localhost;
   Replace localhost with your domain name:
/etc/nginx/sites-available/default
server_name example.com www.example.com;
   Save the file and quit your editor. Verify the syntax of your configuration edits with:
sudo nginx -t
sudo service nginx reload
Step 3 — Obtaining an SSL Certificate
sudo certbot --nginx -d example.com -d www.example.com
   If that's successful, certbot will ask how you'd like to configure your HTTPS settings.
   Select your choice then hit ENTER. The configuration will be updated, and Nginx will reload to pick up the new settings. certbot will   wrap up with a message telling you the process was successful and where your certificates are stored:
Step 4 — Verifying Certbot Auto-Renewal
  To test the renewal process, you can do a dry run with certbot:
sudo certbot renew --dry-run
  We've installed the Let's Encrypt client certbot, downloaded SSL certificates for our domain, configured Nginx to use these certificates, and set up automatic certificate renewal.