NginxPushDocker/nginx.vh.default.conf

127 lines
5.2 KiB
Plaintext

server {
listen 8080 default_server;
server_name localhost;
location /pub {
# activate publisher mode for this location, with admin support
push_stream_publisher admin;
# query string based channel id
push_stream_channels_path $arg_id;
# store messages in memory
push_stream_store_messages on;
# Message size limit
# client_max_body_size MUST be equal to client_body_buffer_size or
# you will be sorry.
client_max_body_size 1m;
client_body_buffer_size 1m;
}
location ~ /sub/(.*) {
# activate subscriber mode for this location
push_stream_subscriber;
# positional channel path
push_stream_channels_path $1;
if ($arg_tests = "on") {
push_stream_channels_path "test_$1";
}
# header to be sent when receiving new subscriber connection
push_stream_header_template "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta http-equiv=\"Cache-Control\" content=\"no-store\">\r\n<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\r\n<meta http-equiv=\"Pragma\" content=\"no-cache\">\r\n<meta http-equiv=\"Expires\" content=\"Thu, 1 Jan 1970 00:00:00 GMT\">\r\n<script type=\"text/javascript\">\r\nwindow.onError = null;\r\ntry{ document.domain = (window.location.hostname.match(/^(\d{1,3}\.){3}\d{1,3}$/)) ? window.location.hostname : window.location.hostname.split('.').slice(-1 * Math.max(window.location.hostname.split('.').length - 1, (window.location.hostname.match(/(\w{4,}\.\w{2}|\.\w{3,})$/) ? 2 : 3))).join('.');}catch(e){}\r\nparent.PushStream.register(this);\r\n</script>\r\n</head>\r\n<body>";
# message template
push_stream_message_template "<div>p(~id~,'~channel~','~text~','~event-id~', '~time~', '~tag~');</div><br/>";
# footer to be sent when finishing subscriber connection
push_stream_footer_template "</body></html>";
# content-type
default_type "text/html; charset=utf-8";
if ($arg_qs = "on") {
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_event_id "$arg_eventid";
}
}
location ~ /ev/(.*) {
# activate event source mode for this location
push_stream_subscriber eventsource;
# positional channel path
push_stream_channels_path $1;
if ($arg_tests = "on") {
push_stream_channels_path "test_$1";
}
if ($arg_qs = "on") {
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_event_id "$arg_eventid";
}
}
location ~ /lp/(.*) {
# activate long-polling mode for this location
push_stream_subscriber long-polling;
# positional channel path
push_stream_channels_path $1;
if ($arg_tests = "on") {
push_stream_channels_path "test_$1";
}
if ($arg_qs = "on") {
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_event_id "$arg_eventid";
}
}
location ~ /jsonp/(.*) {
# activate long-polling mode for this location
push_stream_subscriber long-polling;
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_event_id "$arg_eventid";
# positional channel path
push_stream_channels_path $1;
if ($arg_tests = "on") {
push_stream_channels_path "test_$1";
}
}
location ~ /ws/(.*) {
# activate websocket mode for this location
push_stream_subscriber websocket;
# positional channel path
push_stream_channels_path $1;
if ($arg_tests = "on") {
push_stream_channels_path "test_$1";
}
# store messages in memory
push_stream_store_messages on;
push_stream_websocket_allow_publish on;
if ($arg_qs = "on") {
push_stream_last_received_message_time "$arg_time";
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_event_id "$arg_eventid";
}
}
location / {
#if (!-f $request_filename) {
# proxy_pass "http://localhost:8888";
#}
}
}