Skip to content

Commit f845dc8

Browse files
feat(router): configurable gzip settings
Fixes #884
1 parent 9698f42 commit f845dc8

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

router/bin/boot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ sleep $(($ETCD_TTL+1))
2828
if ! etcdctl --no-sync -C $ETCD ls /deis/services >/dev/null 2>&1; then
2929
etcdctl --no-sync -C $ETCD mkdir /deis/services || true >/dev/null 2>&1
3030
etcdctl --no-sync -C $ETCD set $ETCD_PATH/port ${PORT:-80} >/dev/null
31+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzip on >/dev/null
32+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipHttpVersion 1.0 >/dev/null
33+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipCompLevel 2 >/dev/null
34+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipProxied any >/dev/null
35+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipVary on >/dev/null
36+
etcdctl --no-sync -C $ETCD set $ETCD_PATH/gzipDisable "\"msie6\"" >/dev/null
37+
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
3138
fi
3239

3340
# wait for confd to run once and install initial templates

router/conf.d/nginx.conf.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gid = 0
66
mode = "0644"
77
keys = [
88
"/deis/services",
9+
"/deis/router"
910
]
1011
#check_cmd = "/usr/sbin/nginx -t -c {{ .src }}"
1112
reload_cmd = "/usr/sbin/nginx -s reload"

router/templates/nginx.conf

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,36 @@ worker_processes 4;
66
pid /run/nginx.pid;
77

88
events {
9-
worker_connections 768;
10-
# multi_accept on;
9+
worker_connections 768;
10+
# multi_accept on;
1111
}
1212

1313
http {
1414
# basic settings
15-
sendfile on;
16-
tcp_nopush on;
17-
tcp_nodelay on;
18-
keepalive_timeout 65;
19-
types_hash_max_size 2048;
15+
sendfile on;
16+
tcp_nopush on;
17+
tcp_nodelay on;
18+
keepalive_timeout 65;
19+
types_hash_max_size 2048;
2020
server_names_hash_bucket_size 64;
21-
gzip on;
22-
gzip_disable "msie6";
2321

2422
include /etc/nginx/mime.types;
25-
default_type application/octet-stream;
23+
default_type application/octet-stream;
24+
25+
{{ if .deis_router_gzip }}
26+
gzip {{ .deis_router_gzip }};
27+
gzip_comp_level {{ .deis_router_gzipCompLevel }};
28+
gzip_disable {{ .deis_router_gzipDisable }};
29+
gzip_http_version {{ .deis_router_gzipHttpVersion }};
30+
gzip_types {{ .deis_router_gzipTypes }};
31+
gzip_proxied {{ .deis_router_gzipProxied }};
32+
gzip_vary {{ .deis_router_gzipVary }};
33+
{{ end }}
2634

2735
# send logs to STDOUT so they can be seen using 'docker logs'
2836
access_log /dev/stdout;
2937
error_log /dev/stdout;
3038

31-
3239
server {
3340
listen 80 default_server;
3441
server_name _; # will never match

0 commit comments

Comments
 (0)