python-3.x - 如何为通过 Gunicorn 运行的 Flask 应用程序获取 SSL?

标签 python-3.x ssl flask https gunicorn

我在 Ubuntu 18.04 上通过 Gunicorn 运行 Flask 应用程序。 Gunicorn 在端口 80 上运行。我有 NGINX 设置,但它没有被使用并且被禁用。我能够成功地为 NGINX 设置 cert-bot,但它没有帮助,因为 NGINX 没有被使用,并且它也与端口 80 上的 gunicorn 冲突。是否可以获得专门用于 Gunicorn/Flask 的 SSL 证书或其他东西可以使用它吗? SSL 和 https对页面至关重要。

最佳答案

您可以将 certbot 生成的 SSL 证书与 Gunicorn 一起使用:

  • 关注 certbot instructions对于软件“其他”。请注意保存生成文件的位置。
  • 运行 Gunicorn 并使用 --keyfile 指定证书和 key 路径和 --certfile选项。例子:gunicorn --keyfile /some/path/key.pem --certfile /some/path/cert.pem main:app
  • 关于python-3.x - 如何为通过 Gunicorn 运行的 Flask 应用程序获取 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62714873/

    相关文章:

    python - 将逗号分隔字符串的 Pandas 列转换为整数

    python - docker run 中的flask主机地址

    java - 使用 Netty 的单向 SSL 身份验证

    spring-boot - 将客户端证书与改造 (okhttp) 一起使用时出现 bad_certificate 错误,但与 curl 一起使用时效果很好

    windows - Windows 7 中的自签名证书问题 - 替代解决方案/提示

    python - 如何将 flask-sqlalchemy 与 Google Cloud Functions 一起使用?

    python - 尝试设置 Flask key 时出现奇怪的输出

    python-3.x - python3模拟成员变量多次获取

    python - 引用子类中的类成员

    java - 在 python3 中将 LongBits 转换为 float