2010-07-27 49 views
0

HTTP PUSH的Nginx方法相對簡單。有3方涉及:訂閱者(接收者),發佈者(發送者),服務器本身充當多播服務器。Nginx HTTP PUSH上的會話/授權彗星

Nginx也可以將用戶可以訪問的不同通道ID分成不同的通道。

但我仍然不知道如何授權/限制內容只爲登錄用戶,或只發送該用戶所需的數據,而不是多播給任何人瞭解頻道ID。

如果可能的話,有沒有辦法只使用一個通道並選擇性地向用戶發送數據?

目前我運行在同一個數據庫上,但發件人使用nginx寫入ruby,前端使用PHP/GWT寫入。

非常感謝您

回答

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... 
1

也許你可以使用我的http_push_module模塊的岔路口,它實現了對渠道細粒度的安全訪問。它提供了到期時間,以渠道和每個客戶端的IP /每通道的安全性(它額外增加了JSONP支持,如果你需要它,作爲一個加號):

https://github.com/Kronuz/nginx_http_push_module

使用,你可以給你的登錄模塊在用戶中使用一個有效的密鑰(甚至可以過期,或者只是使用FFFFFFFF,否則作爲過期日期,因此永不過期),並且儘可能限制他們的訪問權限,甚至通過使用嵌入密鑰中的IP地址來「打開「該頻道。我希望這有幫助。