Configuring NGINX to use SSL

Edit the nginx.conf file and edit the server directive to include SSL as follows:

server {   listen               80;   listen               443 ssl;   ssl_certificate      /home/projects/educa/ssl/educa.crt;   ssl_certificate_key  /home/projects/educa/ssl/educa.key;   server_name          www.educaproject.com educaproject.com;   # ...}

With the preceding code, our server now listens both to HTTP through port 80 and HTTPS through port 443. We indicate the path to the SSL certificate with ssl_certificate and the certificate key with ssl_certificate_key.

Restart NGINX with the following command:

sudo service nginx restart

NGINX will load the new configuration. Open https://educaproject.com/ with your browser. You should see a warning message similar to the following ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.