【问题标题】:How run bottle + tornado + ssl (https) + spdy如何运行瓶子 + 龙卷风 + ssl (https) + spdy
【发布时间】:2013-08-01 01:29:02
【问题描述】:

我正在使用带有网络服务器龙卷风的 python 框架瓶。这是我的init.py

import bottle
import os

# Init application
bottle.run(host="127.0.0.1", app=app, port=int(os.environ.get("PORT", 5000)), server='tornado')
  • 如何通过 HTTPS 建立连接?

我读了这篇文章 http://dgtool.blogspot.com/2011/12/ssl-encryption-in-python-bottle.html 但它是关于 CherryPy 服务器的。


  • 是否可以将 SPDY 与 Tornado 一起使用?如何? (我在 GitHub 上找到了 TornadoSPDY,但没有解释如何使用它)

任何帮助表示赞赏

【问题讨论】:

    标签: python ssl tornado bottle spdy


    【解决方案1】:

    最好的办法是使用代理前端服务器,如 nginx、haproxy 或 apache。使用 ssl 配置 tornado 非常慢,它会减慢 tornado 的速度,直到它完全没有响应,只需最少的访问。我到处寻找直接使用龙卷风在 ssl 流量中获得不错的速度,但没有找到任何东西。此外,使用前端服务器也不错。

    但是通过使用 apache f.ex。作为前端代理,我接近原生非 SSL 速度。

    但是用 ssl 配置 tornado 很简单:

    def main():
        handlers = [
            (r"/", HomeHandler),
        ]
        settings = dict(
           blog_title=u"Tornado Blog",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
            debug=True,
            certfile = os.path.join("certs/server.crt"),
            keyfile = os.path.join("certs/server.key"),
            ssl_options = {
                "certfile" : os.path.join("certs/server.crt"),
                "keyfile" : os.path.join("certs/server.key"),
            },
        )
        tornado.options.parse_command_line()
        http_server = tornado.httpserver.HTTPServer(Application())
        http_server.listen(options.port)
        tornado.ioloop.IOLoop.instance().start()
    
    main()
    

    【讨论】:

      猜你喜欢
      • 2013-10-26
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多