-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf.template
83 lines (63 loc) · 2.15 KB
/
nginx.conf.template
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
#user nobody;
worker_processes auto;
worker_rlimit_nofile 100000;
daemon off;
error_log stderr info;
#pid logs/nginx.pid;
events {
worker_connections 90000;
multi_accept on;
}
http {
access_log /dev/stdout;
push_stream_message_ttl 1h;
push_stream_shared_memory_size 700M;
# push_stream_max_subscribers_per_channel 30000;
# Prevent closing channels too fast
push_stream_channel_inactivity_time 1h;
push_stream_max_messages_stored_per_channel 1;
# define publisher and subscriber endpoints in your server context
server {
listen 80 backlog=1024 reuseport;
location / {
return 204;
}
location /channels-stats {
# activate channels statistics mode for this location
push_stream_channels_statistics;
# query string based channel id
push_stream_channels_path $arg_id;
}
location /pub {
# authenticate request
auth_request /auth;
# activate publisher (admin) mode for this location
push_stream_publisher admin;
push_stream_store_messages on;
# query string based channel id
push_stream_channels_path $arg_id;
# cors headers
push_stream_allowed_origins *;
}
location ~ /sub/(.*) {
keepalive_requests 10000;
# activate event source mode for this location
push_stream_subscriber eventsource;
add_header Content-Type "text/event-stream" always;
add_header Access-Control-Allow-Origin *;
# positional channel path
push_stream_channels_path $1;
# message template
push_stream_message_template ~text~;
push_stream_authorized_channels_only on;
# ping frequency
# push_stream_ping_message_interval 2s;
}
location /auth {
if ($http_authorization = "${PUBSUB_SECRET}") {
return 200;
}
return 401;
}
}
}