How to scale and secure Django application with Docker, Nginx, and Let's Encrypt

Click for: original source

In cloud-based environments, there are multiple ways to scale and secure a Django application. By scaling horizontally, and running several copies of your app, you can build a more fault-tolerant and highly-available system, while also increasing its throughput so that requests can be processed simultaneously. By Hanif Jetha.

In this tutorial, you’ll horizontally scale a containerized Django and Gunicorn Polls application by provisioning two application servers that will each run a copy of a Django and Gunicorn app container.

You’ll also enable HTTPS by provisioning and configuring a third proxy server that will run an Nginx reverse proxy container and a Certbot client container. Certbot will provision TLS certificates for Nginx from the Let’s Encrypt certificate authority. This will ensure that your site receives a high security rating from SSL Labs.

The article is split into:

  • Prerequisites
  • Configuring first Django application server
  • Configuring Second Django application server
  • Configuring Nginx Docker container
  • Configuring Certbot and Let’s Encrypt certificate renewal

When building a distributed system, there are often multiple design decisions you must face, and several architectures may satisfy your use case. The architecture described in this tutorial is meant as a flexible blueprint for designing scalable apps with Django and Docker. Nice one!

[Read More]

Tags python web-development app-development infosec nginx ssl servers