From f845dc8fc4a7eeee23b00ab056fadae5b3f065ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Mon, 12 May 2014 15:48:52 -0700 Subject: [PATCH] feat(router): configurable gzip settings Fixes #884 --- router/bin/boot | 7 +++++++ router/conf.d/nginx.conf.toml | 1 + router/templates/nginx.conf | 29 ++++++++++++++++++----------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/router/bin/boot b/router/bin/boot index 26b238d865..ed190391f7 100755 --- a/router/bin/boot +++ b/router/bin/boot @@ -28,6 +28,13 @@ sleep $(($ETCD_TTL+1)) if ! etcdctl --no-sync -C $ETCD ls /deis/services >/dev/null 2>&1; then etcdctl --no-sync -C $ETCD mkdir /deis/services || true >/dev/null 2>&1 etcdctl --no-sync -C $ETCD set $ETCD_PATH/port ${PORT:-80} >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzip on >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipHttpVersion 1.0 >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipCompLevel 2 >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipProxied any >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipVary on >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipDisable "\"msie6\"" >/dev/null + etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipTypes "application/x-javascript, application/xhtml+xml, application/xml, application/xml+rss, application/json, text/css, text/javascript, text/plain, text/xml" >/dev/null fi # wait for confd to run once and install initial templates diff --git a/router/conf.d/nginx.conf.toml b/router/conf.d/nginx.conf.toml index 59bfd2d040..2496de86e0 100644 --- a/router/conf.d/nginx.conf.toml +++ b/router/conf.d/nginx.conf.toml @@ -6,6 +6,7 @@ gid = 0 mode = "0644" keys = [ "/deis/services", + "/deis/router" ] #check_cmd = "/usr/sbin/nginx -t -c {{ .src }}" reload_cmd = "/usr/sbin/nginx -s reload" diff --git a/router/templates/nginx.conf b/router/templates/nginx.conf index d522df59b4..21626af1a3 100644 --- a/router/templates/nginx.conf +++ b/router/templates/nginx.conf @@ -6,29 +6,36 @@ worker_processes 4; pid /run/nginx.pid; events { - worker_connections 768; - # multi_accept on; + worker_connections 768; + # multi_accept on; } http { # basic settings - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; server_names_hash_bucket_size 64; - gzip on; - gzip_disable "msie6"; include /etc/nginx/mime.types; - default_type application/octet-stream; + default_type application/octet-stream; + + {{ if .deis_router_gzip }} + gzip {{ .deis_router_gzip }}; + gzip_comp_level {{ .deis_router_gzipCompLevel }}; + gzip_disable {{ .deis_router_gzipDisable }}; + gzip_http_version {{ .deis_router_gzipHttpVersion }}; + gzip_types {{ .deis_router_gzipTypes }}; + gzip_proxied {{ .deis_router_gzipProxied }}; + gzip_vary {{ .deis_router_gzipVary }}; + {{ end }} # send logs to STDOUT so they can be seen using 'docker logs' access_log /dev/stdout; error_log /dev/stdout; - server { listen 80 default_server; server_name _; # will never match