how can i add ssl certificate to my django website??

Posted October 7, 2020 12.3k views
SecurityLet's Encrypt

I have domain on tmdhosting and pointing to digitalocean host server.
I have django website and now after deploy i want to secure it by ssl . but i faced many problems and errors. so how can i add ssl to my web?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


In order to give you a solid straight forward answer, you must give a more detailed description of your setup.

However, in general you don’t deal with SSL in your application. Instead, it is normal practice to handle SSL with a dedicated HTTP-server program, such as Nginx or Apache.

By using DigitalOcean’s App Platform-solution all of that is handled for you.

On the contrary, if you are running your own Droplet with, let’s say, Ubuntu 20.04 and Apache you want to do the following:

  1. Determine what port your Django app is listening on (default is localhost:8000).
  2. Setup a virtual host on Apache for your domain. (Don’t bother with SSL yet!.)
  3. Configure the virtual host frem step 2 to reverse proxy all the incoming requests to your Django app (e.g. localhost:8000).
  4. Test that the setup works as expected. By now you should be able to communicate with your Django app over http://your-domain
  5. Now, wrap it up by adding SSL to your Apache virtual host with Let’s Encrypt and you should then be able to access your Django app over SSL https://your-domain

Good luck! :)

by Mateusz Papiernik
In this tutorial, you will set up Apache as a reverse proxy using the `mod_proxy` extension to redirect incoming connections to underlying application server(s) running on the same network. There are instructions on setting up a simple web app using the Flask framework to show how Apache interacts with the real application hidden behind it, but you can also follow this tutorial using your existing application server, if you have one.