-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnchan.conf.erb
77 lines (64 loc) · 2.44 KB
/
nchan.conf.erb
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
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NCHAN_WORKERS'] || 'auto' %>;
events {
use epoll;
accept_mutex on;
worker_connections <%= ENV['NCHAN_WORKER_CONNECTIONS'] || 1024 %>;
}
http {
gzip on;
gzip_comp_level 6;
gzip_min_length 512;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
gzip_proxied any;
server_tokens off;
access_log logs/access.log;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/access.log l2met;
error_log logs/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
#Must read the body in 5 seconds.
client_body_timeout 5;
server {
listen <%= ENV["PORT"] %>;
server_name _;
charset UTF-8;
port_in_redirect off;
keepalive_timeout 5;
# You can now subscribe to channels by GETing /sub?id=channel_id
location = /sub {
nchan_subscriber;
nchan_channel_id $arg_id;
nchan_subscriber_timeout <%= ENV['NCHAN_SUB_TIMEOUT'] || 25 %>;
}
# You can now publish messages to channels by POSTing data to /pub?id=channel_id
location = /pub {
nchan_publisher;
nchan_channel_id $arg_id;
}
location = /pubsub {
nchan_pubsub;
nchan_channel_id $arg_id;
nchan_subscriber_timeout <%= ENV['NCHAN_SUB_TIMEOUT'] || 25 %>;
}
location = /sub-split/(.*)$ {
nchan_subscriber;
nchan_channel_id "$1";
nchan_channel_id_split_delimiter ",";
nchan_subscriber_timeout <%= ENV['NCHAN_SUB_TIMEOUT'] || 25 %>;
# GET /multisub-split/foo,bar,baz,a will be subscribed to:
# channels 'foo', 'bar', 'baz', and 'a'
# and will receive messages from all of the above.
}
# location / {
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_redirect off;
# proxy_pass http://app_server;
# }
}
}