Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could i use let's encrypt behind a django application without stopping the server?

I have a django application running on a server. I want to use let's encrypt to provide an encrypted connection. I could use the standalone option of their ACME client, but i don't want to stop my server, what i would have to do.

So there is the webroot option, that work with my allready running webserver (nginx). Django would process the request in this case. My question is, how should it look like on the django side to get this running (keeping automated renewal several months in mind)?

like image 333
pritstift Avatar asked Dec 02 '25 09:12

pritstift


2 Answers

I don't know what setup others use, but I generally set up Django apps with Nginx serving static content and Gunicorn as the application server. It's widely accepted that Django apps usually use this kind of two web server setup. The standard instructions for setting up Let's Encrypt with Nginx worked fine for me.

Or Digital Ocean have an excellent guide too.

EDIT: It looks like Nginx can do a "graceful" reload that just updates the config with no downtime. For Debian or Ubuntu pre Systemd this would be sudo service nginx reload, while for a distro with Systemd the command is sudo systemctl reload nginx.service.

like image 135
Matthew Daly Avatar answered Dec 04 '25 00:12

Matthew Daly


In case other users come this way like I did from Google, here's how I improved this situation:

I was unsatisfied by my options when it came to creating ACME challenges for Let's Encrypt when running a Django application. So, I rolled my own solution and created a Django app! Basically, you can manage your ACME challenges as just another object, and the app will produce the proper end-point URL.

Yes you are installing an app which means a deploy / update to your app, but once you've done that managing your challenges is far easier in the long run.

Simply pip install django-letsencrypt and follow the README to be on your way.

like image 31
Urda Avatar answered Dec 04 '25 01:12

Urda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!