Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

./manage.py runserver with https

./manage.py runserver 0.0.0.0:8000

I am using the line above as part of the code I borrowed from github (https://github.com/ribeiroit/boh-puppet) to run bag of holding installation.

So far so good on http but not https. How do I modify the line above to incorporate https? I have already obtained ssl certificate from Comodo and updated my nginx conf.d file but the website won't display in https. Any ideas please shoot my way.

Thank you

like image 201
Adiza Baakoe Avatar asked Jan 23 '26 20:01

Adiza Baakoe


2 Answers

While cezar's recommendation of django-extensions is valid to run a server with https, neither runserver or runserver_plus should ever be used in a production setting.

Quoting Django's documentation:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

Quoting django-extensions' documentation:

WARNING: This should never be used in any kind of production environment. Not even for a quick problem check. I cannot emphasize this enough. The interactive debugger allows you to evaluate python code right against the server. You’ve been warned.

Now yes, this warning from the django-extensions documentation is in reference to a single feature, the interactive console, which will theoretically not be exposed if DEBUG is set to False. But this is precisely how Patreon got hacked, and probably others as well. Why even risk it?

Instead, it would be far better to deploy your application using one of the officially recommended WSGI servers such as gunicorn or uWSGI.

like image 128
Joey Wilhelm Avatar answered Jan 26 '26 12:01

Joey Wilhelm


For this purpose I use the the third-party app django-extensions, which offers some nice additional functionalities.

One of those extras is RunServerPlus.

You can then start the server like this:

python manage.py runserver_plus --cert-file /path/to/your/certificate

and open https://localhost:8000 in your browser.

like image 36
cezar Avatar answered Jan 26 '26 11:01

cezar



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!