简体   繁体   English

./manage.py 运行服务器与 https

[英]./manage.py runserver with https

./manage.py runserver 0.0.0.0:8000 ./manage.py 运行服务器 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.我使用上面的行作为我从 github ( https://github.com/ribeiroit/boh-puppet ) 借来的代码的一部分来运行包安装。

So far so good on http but not https.到目前为止,在 http 上还不错,但在 https 上不行。 How do I modify the line above to incorporate https?如何修改上面的行以合并 https? I have already obtained ssl certificate from Comodo and updated my nginx conf.d file but the website won't display in https.我已经从 Comodo 获得了 ssl 证书并更新了我的 nginx conf.d 文件,但该网站不会在 https 中显示。 Any ideas please shoot my way.任何想法请按我的方式拍摄。

Thank you谢谢

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.虽然 cezar 对django-extensions的推荐对于使用 https 运行服务器是有效的,但是runserverrunserver_plus都不应该在生产环境中使用。

Quoting Django's documentation :引用Django 的文档

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.) (这就是它的保留方式。我们的工作是制作 Web 框架,而不是 Web 服务器,因此改进此服务器以处理生产环境超出了 Django 的范围。)

Quoting django-extensions' documentation :引用django-extensions 的文档

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.交互式调试器允许您针对服务器评估 Python 代码。 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 .现在是的, django-extensions文档中的这个警告是针对单个功能的,即交互式控制台,如果DEBUG设置为False ,理论上不会公开。 But this is precisely how Patreon got hacked , and probably others as well.但这正是Patreon 被黑客入侵的方式,也可能是其他人。 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 .相反,使用官方推荐的WSGI 服务器之一(例如gunicornuWSGI )部署应用程序会好得多

For this purpose I use the the third-party app django-extensions , which offers some nice additional functionalities.为此,我使用第三方应用程序django-extensions ,它提供了一些不错的附加功能。

One of those extras is RunServerPlus .这些附加功能之一是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.并在浏览器中打开https://localhost:8000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM