kvm, slaprunner: use toolbox 0.40.4
[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   listen $${nginx-configuration:local_ip}:$${nginx-configuration:port};
60
61   fastcgi_temp_path  $${directory:varnginx} 1 2;
62   uwsgi_temp_path  $${directory:varnginx} 1 2;
63   scgi_temp_path  $${directory:varnginx} 1 2;
64
65   client_body_temp_path $${directory:varnginx} 1 2;
66   proxy_temp_path $${directory:varnginx} 1 2;
67
68   ## Serve an error 204 (No Content) for favicon.ico
69   location = /favicon.ico {
70     return 204;
71   }
72
73   location /pub {
74             push_stream_publisher;
75
76             push_stream_channels_path               $arg_id;
77             # store messages in memory
78             push_stream_store_messages              $${nginx-configuration:publisher_push_stream_store_messages};
79
80             # Message size limit
81             # client_max_body_size MUST be equal to client_body_buffer_size or
82             # you will be sorry.
83             client_max_body_size                    $${nginx-configuration:publisher_client_max_body_size};
84             client_body_buffer_size                 $${nginx-configuration:publisher_client_body_buffer_size};
85
86    }
87
88    location ~ /sub/(.*) {
89             # activate subscriber mode for this location
90             add_header "Access-Control-Allow-Origin" $${nginx-configuration:subscriber_allow_origin};
91             add_header 'Access-Control-Allow-Credentials' $${nginx-configuration:subscriber_allow_credential};
92             add_header 'Access-Control-Allow-Methods' $${nginx-configuration:subscriber_allow_methods};
93             add_header 'Access-Control-Allow-Headers' $${nginx-configuration:subscriber_allow_headers};
94
95             push_stream_subscriber eventsource;
96             # positional channel path
97             push_stream_channels_path                   $1;
98
99             # content-type
100             default_type                                "text/event-stream; charset=utf-8";
101   }
102
103   location / {
104       root $${directory:www};
105   }
106 }
107 }