django - 将 Gunicorn 用于 Django 的 SSL

标签 django ssl nginx gunicorn

我正在使用 gunicorn 运行一个 django 项目,我想使用 ssl 运行它,我在互联网上发现我需要这本字典 "{'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED -SSL':'开'}”。 但是我应该把它放在哪里呢?有没有办法在命令 gunicorn_django 上使用 ssl 运行它? 我没有使用 nginx,我也不想使用。 谢谢。

最佳答案

更新:Gunicorn 添加了 SSL 支持 0.17.0 / 2012-12-25 .

原答案:

Gunicorn 本身不支持 SSL。有一个开放的拉取请求来添加它 https://github.com/benoitc/gunicorn/pull/265 . X-FORWARDED-PROTOCOLX-FORWARDED-SSL header 将由执行 SSL 终止的 Gunicorn 前面的代理(例如 Nginx)使用。

使用 SSL 不需要使用 Nginx。您可以使用 Apache/mod_proxy 或 HAProxy 或任何其他支持 SSL 的代理服务器。即使不需要 SSL,在使用 Gunicorn 缓冲慢速客户端时也建议使用代理服务器 http://gunicorn.org/deploy.html

Although there are many HTTP proxies available, we strongly advise that you use Nginx. If you choose another proxy server you need to make sure that it buffers slow clients when you use default Gunicorn workers. Without this buffering Gunicorn will be easily susceptible to denial-of-service attacks. You can use slowloris to check if your proxy is behaving properly.

关于django - 将 Gunicorn 用于 Django 的 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11568672/

相关文章:

python - 如何将 Model.objects.all() 限制为属于一个组织的数据

python - 在 Django 的 ORM 中使用带有 UPDATE 的子查询

php - SSL_ERROR_PROTOCOL_VERSION_ALERT : Peer reports incompatible or unsupported protocol version

c# - 将 ssl 添加到 webapi...也添加到客户端?

ssl - 在 Nginx 和 Daphne 中使用 WebSocket Secure

django - 如何使用 django-storages 生成预先签名的 S3 url?

python - 安装 LAMP 会修复 Django/MySQL 配置问题吗?

css - 混合内容 - 不安全的样式表

php - Laravel - 发布请求空字段

nginx - 在 Nginx 中包含虚拟主机文件