【问题标题】:Session/authorize comet on Nginx HTTP PUSHNginx HTTP PUSH上的会话/授权彗星
【发布时间】:2010-12-05 01:15:35
【问题描述】:

HTTP PUSH 的 Nginx 方法相对简单。涉及3方:订阅者(接收者),发布者(发送者),服务器本身充当多播服务器。

Nginx 也可以分成不同的频道,用户可以访问不同的频道 ID。

但我仍然不知道如何只为登录用户授权/限制内容,或者只向该用户发送所需的数据,而不是将其多播给任何知道频道 ID 的人。

如果可能的话,是否只使用一个通道并有选择地向用户发送数据?

目前我在同一个数据库上运行,但是 Sender 是用 ruby​​ 编写的,使用 nginx,前端是使用 PHP/GWT 编写的。

非常感谢

【问题讨论】:

    标签: php ruby gwt nginx comet


    【解决方案1】:

    这是我的设置: >

                  location = /broadcast/sub {
                       default_type  text/json;
                      set $push_channel_id $arg_channel;
                      push_subscriber;
                      push_subscriber_concurrency broadcast;
                      push_channel_group broadcast;
                  }
    
                  location = /broadcast/pub {
                      set $push_channel_id $arg_channel;
                      push_publisher;
                      push_min_message_buffer_length 5;
                      push_max_message_buffer_length 20;
                      push_message_timeout 10s;
                      push_channel_group broadcast;
                  }
    
    I send new messages with curl
    
        $ch = curl_init($pub_url);
        $data = array('status' => $message);
        curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:
    text/json"));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $return = curl_exec($ch);
        curl_close($ch);
    
    Thanks for any hints...
    

    【讨论】:

      【解决方案2】:

      也许你可以使用我的 http_push_module 模块的分支,它实现了对通道的细粒度安全访问。它提供了通道的过期时间和每个客户端 IP/每个通道的安全性(如果您需要它,它还添加了 jsonp 支持,作为一个优点):

      https://github.com/Kronuz/nginx_http_push_module

      使用该模块,您可以为登录的用户提供一个有效的密钥来使用(它甚至可以过期,或者只使用 FFFFFFFF 作为过期日期,这样它就永远不会过期),并且可以根据需要限制他们的访问权限,甚至通过使用嵌入在密钥中的 IP 地址来“打开”通道。我希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 2010-11-12
        • 2011-07-30
        • 2011-12-07
        • 1970-01-01
        • 2011-01-13
        • 1970-01-01
        • 2011-03-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多