V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · 5275 views
    This topic created in 3915 days ago, the information mentioned may be changed or developed.

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

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

    proxy_set_header Host $host;

    然后tornado中:

    self.request.host可以取的到
    spritevan
        3
    spritevan  
       Aug 9, 2015
    <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   ·   Solana   ·   3204 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 00:03 · PVG 08:03 · LAX 17:03 · JFK 20:03
    ♥ Do have faith in what you're doing.