Last active
January 27, 2016 07:38
-
-
Save aregee/a2c0197063039c036451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pid logs/nginx.pid; | |
error_log logs/nginx-main_error.log debug; | |
# Development Mode | |
master_process off; | |
daemon off; | |
worker_rlimit_core 2500M; | |
working_directory /tmp; | |
debug_points abort; | |
env MOCKEAGAIN_VERBOSE; | |
env MOCKEAGAIN_WRITE_TIMEOUT_PATTERN; | |
#env MOCKEAGAIN; | |
env LD_PRELOAD; | |
worker_processes 2; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} | |
http { | |
postpone_output 1; # only postpone a single byte, default 1460 bytes | |
access_log logs/nginx-http_access.log; | |
client_max_body_size 500M; | |
push_stream_shared_memory_size 100m; | |
push_stream_max_channel_id_length 200; | |
# max messages to store in memory | |
push_stream_max_messages_stored_per_channel 20; | |
# message ttl | |
push_stream_message_ttl 5m; | |
# ping frequency | |
push_stream_ping_message_interval 30s; | |
# connection ttl to enable recycle | |
push_stream_subscriber_connection_ttl 15m; | |
# connection ttl for long polling | |
push_stream_longpolling_connection_ttl 30s; | |
push_stream_timeout_with_body off; | |
# wildcard | |
push_stream_wildcard_channel_prefix "broad_"; | |
push_stream_wildcard_channel_max_qtd 3; | |
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":~text~, \"tag\":\"~tag~\", \"time\":\"~time~\", \"eventid\":\"~event-id~\"}"; | |
# subscriber may create channels on demand or only authorized (publisher) may do it? | |
push_stream_authorized_channels_only off; | |
push_stream_allowed_origins "*"; | |
server { | |
listen 80 default_server; | |
root /home/ubuntu/d2i-run/public; | |
index index.html index.htm; | |
# Make site accessible from http://localhost/ | |
server_name localhost; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
#try_files $uri $uri/ =404; | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
proxy_pass http://127.0.0.1:3000; | |
} | |
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests | |
#location /RequestDenied { | |
# proxy_pass http://127.0.0.1:8080; | |
#} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
#error_page 500 502 503 504 /50x.html; | |
#location = /50x.html { | |
# root /usr/share/nginx/html; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
#location ~ \.php$ { | |
# fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini | |
# | |
# # With php5-cgi alone: | |
# fastcgi_pass 127.0.0.1:9000; | |
# # With php5-fpm: | |
# fastcgi_pass unix:/var/run/php5-fpm.sock; | |
# fastcgi_index index.php; | |
# include fastcgi_params; | |
#} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
server { | |
listen 9080 default_server; | |
#listen 9443 ssl; | |
#ssl_certificate /usr/local/nginx/ssl/server.crt; | |
#ssl_certificate_key /usr/local/nginx/ssl/server.key; | |
server_name localhost; | |
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 { | |
# 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 32k; | |
client_body_buffer_size 32k; | |
} | |
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 "<script>p(~id~,'~channel~','~text~','~event-id~', '~time~', '~tag~');</script>"; | |
# 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"; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment