1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
h1(#subscribers_configuration). Subscribers Configuration
h2(#push_stream_subscriber). push_stream_subscriber <a name="push_stream_subscriber" href="#"> </a>
*syntax:* _push_stream_subscriber [streaming | polling | long-polling | eventsource | websocket]_
*default:* _streaming_
*context:* _location_
Defines a location as a subscriber. This location represents a subscriber's interface to a channel's message queue.
This location only supports GET http method to receive published messages.
The polling and long-polling modes could be set by the request header *X-Nginx-PushStream-Mode* overriding push_stream_subscriber directive value, except for websocket.
The eventsource mode enable "Event Source":eventsource_ref support for subscribers, using the headers Event-ID and Event-Type on publish is possible to set values to _id:_ and _event:_ attributes on message sent to subscribers.
The websocket mode enable subscriber to use WebSocket protocol.
<pre>
# streaming subscriber location
location /sub/(.*) {
push_stream_subscriber;
# positional channel path
push_stream_channels_path $1;
}
curl -s --no-buffer localhost/sub/ch1 -H 'X-Nginx-PushStream-Mode:polling' #polling request on a streaming location
curl -s --no-buffer localhost/sub/ch1 -H 'X-Nginx-PushStream-Mode:long-polling' #long-polling request on a streaming location
# polling subscriber location
location /sub/(.*) {
push_stream_subscriber polling;
# positional channel path
push_stream_channels_path $1;
}
curl -s --no-buffer localhost/sub/ch1 #polling request
curl -s --no-buffer localhost/sub/ch1 -H 'X-Nginx-PushStream-Mode:long-polling' #long-polling request on a polling location
# long polling subscriber location
location /sub/(.*) {
push_stream_subscriber long-polling;
# positional channel path
push_stream_channels_path $1;
}
curl -s --no-buffer localhost/sub/ch1 #long-polling request
curl -s --no-buffer localhost/sub/ch1 -H 'X-Nginx-PushStream-Mode:polling' #polling request on a logn-polling location
# eventsource subscriber location
location /sub/(.*) {
push_stream_subscriber eventsource;
# positional channel path
push_stream_channels_path $1;
}
curl -s --no-buffer localhost/sub/ch1 #eventsource request
# eventsource subscriber location
location /sub/(.*) {
push_stream_subscriber websocket;
# positional channel path
push_stream_channels_path $1;
}
</pre>
h2(#push_stream_channels_path). push_stream_channels_path <a name="push_stream_channels_path" href="#"> </a>
*values:* _set of channels id and backtrack desired messages_
*location:* _push_stream_subscriber_
A string representing a set of channels id and backtrack desired messages separated by slash, example _/channel1.b3/channel2.b5/channel3.b2_.
The backtrack means the amount of old messages from each of the channels that will be delivered to the subscriber. On the example will be 3 messages from channel1, 5 from channel2 and 2 from channel3.
Backtrack isn't needed, you can only sign channels without get old messages, or you can mix things.
More accepted examples: _/channel1_ , _/channel1/channel2_ , _/channel1.b5/channel2_ , _/channel1/channel2.b6_ , ...
"*How is it used on a publisher location?*":push_stream_channels_path
<pre>
location /sub/(.*) {
push_stream_channels_path $1;
}
#channels path is now part of url
#(/sub/channel_id_string or /sub/channel_id_string.b2/other_channel)
</pre>
h2(#push_stream_authorized_channels_only). push_stream_authorized_channels_only <a name="push_stream_authorized_channels_only" href="#"> </a>
*syntax:* _push_stream_authorized_channels_only on | off_
*default:* _off_
*context:* _location (push_stream_subscriber)_
When set to on, subscribers can connect only to a channel with at least one stored message.
All subscriber requests to nonexistent channels or channels without stored messages will get a 403 Forbidden response.
This restriction is not applied to wildcard channels, but to connect to a wildcard channel is necessary to connect to at least one normal channel on the same request.
h2(#push_stream_header_template_file). push_stream_header_template_file <a name="push_stream_header_template_file" href="#"> </a>
*syntax:* _push_stream_header_template_file string_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The path of a file with the text that will be sent to subscribers when they arrive, except when long polling connections timed out.
The file is read only once on server startup.
Must not be used on the same level (http/server/location block) of push_stream_header_template directive.
h2(#push_stream_header_template). push_stream_header_template <a name="push_stream_header_template" href="#"> </a>
*syntax:* _push_stream_header_template string_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The text that will be sent to subscribers when they arrive, except when long polling connections timed out.
Must not be used on the same level (http/server/location block) of push_stream_header_template_file directive.
h2(#push_stream_message_template). push_stream_message_template <a name="push_stream_message_template" href="#"> </a>
*syntax:* _push_stream_message_template string_
*default:* _==~text~==_
*context:* _location (push_stream_subscriber)_
The text template that will be used to format the message before be sent to subscribers. The template can contain any number of the reserved words: ==~id~, ~text~, ~size~, ~channel~, ~time~, ~tag~, ~event-id~ and ~event-type~, example: "<script>p(~id~,'~channel~','~text~', ~tag~, '~time~');</script>"==
h2(#push_stream_footer_template). push_stream_footer_template <a name="push_stream_footer_template" href="#"> </a>
*syntax:* _push_stream_footer_template string_
*default:* _none_
*context:* _location (push_stream_subscriber)_
*release version:* _0.2.6_
The text that will be sent to subscribers before connection is closed (channel deleted or subscriber timeout), except when long polling connections timed out.
h2(#push_stream_wildcard_channel_max_qtd). push_stream_wildcard_channel_max_qtd <a name="push_stream_wildcard_channel_max_qtd" href="#"> </a>
*syntax:* _push_stream_wildcard_channel_max_qtd number_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The maximum number of wildcard channels that a subscriber may sign on the request.
This directive works in conjunction with "push_stream_authorized_channels_only":push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent wildcard channels.
h2(#push_stream_ping_message_interval). push_stream_ping_message_interval <a name="push_stream_ping_message_interval" href="#"> </a>
*syntax:* _push_stream_ping_message_interval time_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The time interval in which a keepalive message is sent to subscribers. If you do not want to send ping messages, just not set this directive.
h2(#push_stream_subscriber_connection_ttl). push_stream_subscriber_connection_ttl <a name="push_stream_subscriber_connection_ttl" href="#"> </a>
*syntax:* _push_stream_subscriber_connection_ttl time_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The length of time a subscriber will stay connected before it is considered expired and disconnected. If you do not want subscribers to be automatically disconnected, just not set this directive.
h2(#push_stream_longpolling_connection_ttl). push_stream_longpolling_connection_ttl <a name="push_stream_longpolling_connection_ttl" href="#"> </a>
*syntax:* _push_stream_longpolling_connection_ttl time_
*default:* _value in push_stream_subscriber_connection_ttl_
*context:* _location (push_stream_subscriber)_
*release version:* _0.3.1_
The length of time a long polling subscriber will stay connected waiting for a message before it is disconnected. If you do not want subscribers to be automatically disconnected, just not set this directive and push_stream_longpolling_connection_ttl directive.
h2(#push_stream_timeout_with_body). push_stream_timeout_with_body <a name="push_stream_timeout_with_body" href="#"> </a>
*syntax:* _push_stream_timeout_with_body on | off_
*default:* _off_
*context:* _location (push_stream_subscriber)_
*release version:* _0.4.0_
When set to on will send a http 200 message indicating that a timeout happens on long polling connections instead of send only a http 304 header.
h2(#push_stream_websocket_allow_publish). push_stream_websocket_allow_publish <a name="push_stream_websocket_allow_publish" href="#"> </a>
*syntax:* _push_stream_websocket_allow_publish on | off_
*default:* _off_
*context:* _location_
*release version:* _0.3.2_
Enable a WebSocket subscriber send messages to the channel(s) it is connected through the same connection it is receiving the messages, using _send_ method from WebSocket interface.
h2(#push_stream_allow_connections_to_events_channel). push_stream_allow_connections_to_events_channel <a name="push_stream_allow_connections_to_events_channel" href="#"> </a>
*syntax:* _push_stream_allow_connections_to_events_channel on | off_
*default:* _off_
*context:* _location_
*release version:* _0.6.0_
Enable subscriptions to events channel.
h2(#push_stream_last_received_message_time). push_stream_last_received_message_time <a name="push_stream_last_received_message_time" href="#"> </a>
*syntax:* _push_stream_last_received_message_time string_
*default:* _none_
*context:* _location_
*release version:* _0.3.3_
Set the time when last message was received. With that the server knows which messages has to be sent to subscriber. Is a replacement for If-Modified-Since header. Example, $arg_time indicate that the value will be taken from time argument.
h2(#push_stream_last_received_message_tag). push_stream_last_received_message_tag <a name="push_stream_last_received_message_tag" href="#"> </a>
*syntax:* _push_stream_last_received_message_tag string_
*default:* _none_
*context:* _location_
*release version:* _0.3.3_
Set the tag of the last received message. With that the server knows which messages has to be sent to subscriber. Is a replacement for If-None-Match header. Example, $arg_tag indicate that the value will be taken from tag argument.
h2(#push_stream_last_event_id). push_stream_last_event_id <a name="push_stream_last_event_id" href="#"> </a>
*syntax:* _push_stream_last_event_id string_
*default:* _none_
*context:* _location_
*release version:* _0.4.0_
Set the last event id of a message. With that the server knows which messages has to be sent to subscriber. Is a replacement for Last-Event-Id header. Example, $arg_last_event indicate that the value will be taken from last_event argument.
h2(#push_stream_user_agent). push_stream_user_agent <a name="push_stream_user_agent" href="#"> </a>
*syntax:* _push_stream_user_agent string_
*default:* _http user-agent header_
*context:* _location_
*release version:* _0.3.3_
Set from where the user agent will be get to be used on validation for the need of padding. Is a replacement for User-Agent header. Example, $arg_ua indicate that the value will be take from ua argument.
h2(#push_stream_padding_by_user_agent). push_stream_padding_by_user_agent <a name="push_stream_padding_by_user_agent" href="#"> </a>
*syntax:* _push_stream_padding_by_user_agent string_
*default:* _none_
*context:* _location_
*release version:* _0.3.3_
Set the minimum header size and minimum message size to each user agent who match the given expression. The value may be compound for many groups on the format _user-agent-regexp,header_min_size,message_min_size_ separate by a colon (_:_) .
h2(#push_stream_allowed_origins). push_stream_allowed_origins <a name="push_stream_allowed_origins" href="#"> </a>
*syntax:* _push_stream_allowed_origins string_
*default:* _none_
*context:* _location (push_stream_publisher, push_stream_channels_subscriber)_
*release version:* _0.3.4_
Set the value used on the Access-Control-Allow-Origin header to allow cross domain requests by javascript.
You can use a variable as value to this directive.
When this directive is set, the module will set Access-Control-Allow-Methods and Access-Control-Allow-Headers headers with proper values.
[eventsource_ref]http://dev.w3.org/html5/eventsource/
[push_stream_authorized_channels_only]subscribers.textile#push_stream_authorized_channels_only
[push_stream_channels_path]publishers.textile#push_stream_channels_path
|