Merge remote-tracking branch 'origin/master' into erp5-component
[slapos.git] / software / nginx-push-stream / template-nginx.cfg.in
1 daemon off; # run in the foreground so supervisord can look after it
2
3 worker_processes 4;
4 pid $${directory:run}/nginx.pid;
5
6 events {
7   worker_connections 768;
8   # multi_accept on;
9 }
10
11 error_log $${nginx-configuration:error_log};
12
13 http {
14
15   ##
16   # Basic Settings
17   ##
18
19   sendfile on;
20   tcp_nopush on;
21   tcp_nodelay on;
22   keepalive_timeout 65;
23   types_hash_max_size 2048;
24   server_tokens off;
25
26   # server_names_hash_bucket_size 64;
27   # server_name_in_redirect off;
28
29   default_type application/octet-stream;
30   include ${nginx-push-stream-output:mime};
31
32   ##
33   # Logging Settings
34   ##
35
36   access_log $${nginx-configuration:access_log};
37   error_log $${nginx-configuration:error_log};
38
39   ##
40   # Gzip Settings
41   ##
42
43   gzip on;
44   gzip_disable "msie6";
45
46   gzip_vary on;
47   gzip_proxied any;
48   gzip_comp_level 6;
49   gzip_buffers 16 8k;
50   gzip_http_version 1.1;
51   gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
52   ##
53   # Push stream Settings
54   ##
55   push_stream_shared_memory_size                32m;
56
57 server {
58   listen [$${nginx-configuration:ip}]:$${nginx-configuration:port};
59
60   fastcgi_temp_path  $${directory:varnginx} 1 2;
61   uwsgi_temp_path  $${directory:varnginx} 1 2;
62   scgi_temp_path  $${directory:varnginx} 1 2;
63
64   client_body_temp_path $${directory:varnginx} 1 2;
65   proxy_temp_path $${directory:varnginx} 1 2;
66
67   ## Serve an error 204 (No Content) for favicon.ico
68   location = /favicon.ico {
69     return 204;
70   }
71
72   location /pub {
73             push_stream_publisher;
74
75             push_stream_channels_path               $arg_id;
76             # store messages in memory
77             push_stream_store_messages              $${nginx-configuration:publisher_push_stream_store_messages};
78
79             # Message size limit
80             # client_max_body_size MUST be equal to client_body_buffer_size or
81             # you will be sorry.
82             client_max_body_size                    $${nginx-configuration:publisher_client_max_body_size};
83             client_body_buffer_size                 $${nginx-configuration:publisher_client_body_buffer_size};
84
85    }
86
87    location ~ /sub/(.*) {
88             # activate subscriber mode for this location
89             add_header "Access-Control-Allow-Origin" $${nginx-configuration:subscriber_allow_origin};
90             add_header 'Access-Control-Allow-Credentials' $${nginx-configuration:subscriber_allow_credential};
91             add_header 'Access-Control-Allow-Methods' $${nginx-configuration:subscriber_allow_methods};
92             add_header 'Access-Control-Allow-Headers' $${nginx-configuration:subscriber_allow_headers};
93
94             push_stream_subscriber eventsource;
95             # positional channel path
96             push_stream_channels_path                   $1;
97
98             # content-type
99             default_type                                "text/event-stream; charset=utf-8";
100   }
101
102   location / {
103       root $${directory:www};
104   }
105 }
106 }