REST APIs with Flask and Python
  • Introduction
  • Note
  • Domains and HTTPS
    • What is a domain?
    • Purchasing a domain
    • Changing the Authoritative name servers
    • Modifying our DNS records
    • Getting an SSL certificate
    • Serving HTTPS traffic with nginx
Powered by GitBook
On this page
  1. Domains and HTTPS

Getting an SSL certificate

PreviousModifying our DNS recordsNextServing HTTPS traffic with nginx

Last updated 7 years ago

Before continuing, make sure your domain and associated web application works well. Access your domain name and test your app using Postman if necessary!

Using Google Chrome, go to your CloudFlare page and click on the "Crypto" tab in the top menu. Here is where we'll generate the SSL certificate. Other browsers may or may not work for the generation of the SSL certificate and key.

In the Origin Certificates section, press Create Certificate.

Leaving everything as the default, press Next.

You should then see a screen as the below:

These are the SSL certificate key and pem files, which the server needs to enable HTTPS.

Copying the files into the server

Log in to your DigitalOcean server via SSH. This can be done as we have already seen, using a console window, or via the DigitalOcean control panel.

Here, I will create two files. Make sure to replace the domain name for your own:

  • /var/www/ssl/rest-api-course-trial.com.pem ; and

  • /var/www/ssl/rest-api-course-trial.com.key.

In each, paste the corresponding text from the CloudFlare SSL certificate generation window. In the .pem file paste the Origin Certificate field contents, and in the .key file paste the Private Key field contents.

Voilà! You have an active, signed SSL certificate in your server!

The last thing remaining is to tell nginx to use the SSL certificate and serve traffic via https. Let's do that!