Tornado Documentation
› http://www.v2ex.com/tornado/
Tornado on GitHub
› https://github.com/facebook/tornado/
Tornado Gists
› http://tornadogists.org/
xlzd
V2EX  ›  Tornado

tornado 多个 url

  •  1
     
  •   xlzd · Aug 8, 2015 · 5601 views
    This topic created in 4105 days ago, the information mentioned may be changed or developed.

    请问各位, 服务器端用的tornado, 假如几个domain都指向了同一个地址, 应该怎么得到被访问的域名呢?

    3 replies  •  2015-08-09 00:50:49 +08:00
    zjxubinbin
    zjxubinbin
    Aug 8, 2015
    1
    你想是问Tornado怎么实现Vhost吧,用Nginx就行了呀,不同的Hostname转发给不同的Tornado实例.
    janxin
    janxin
    Aug 8, 2015❤️1
    2
    如果前面有nginx的话,设置

    proxy_set_header Host $host;

    然后tornado中:

    self.request.host可以取的到
    spritevan
    spritevan
    Aug 9, 2015
    3
    <https://github.com/tornadoweb/tornado/blob/master/tornado/web.py#L1705>

    """
    We support virtual hosts with the `add_handlers` method, which takes in
    a host regular expression as the first argument::

    application.add_handlers(r"www\.myhost\.com", [
    (r"/article/([0-9]+)", ArticleHandler),
    ])
    """
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:07 · PVG 16:07 · LAX 00:07 · JFK 03:07
    ♥ Do have faith in what you're doing.