Skip to content

Commit dd628fb

Browse files
committed
Add Brotli support
1 parent 0df193e commit dd628fb

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN set -x \
88
&& apt-get install -y --no-install-suggests \
99
libluajit-5.1-dev libpam0g-dev zlib1g-dev libpcre3-dev libpcre2-dev \
1010
libexpat1-dev git curl build-essential lsb-release libxml2 libxslt1.1 libxslt1-dev autoconf libtool libssl-dev \
11-
unzip libmaxminddb-dev
11+
unzip libmaxminddb-dev libbrotli-dev
1212

1313
ARG openresty_package_version=1.27.1.1-1~bookworm1
1414
RUN set -x \
@@ -38,7 +38,7 @@ RUN set -x \
3838
module_repo=$(echo $module | sed -E 's@^(((https?|git)://)?[^:]+).*@\1@g'); \
3939
module_tag=$(echo $module | sed -E 's@^(((https?|git)://)?[^:]+):?([^:/]*)@\4@g'); \
4040
dirname=$(echo "${module_repo}" | sed -E 's@^.*/|\..*$@@g'); \
41-
git clone "${module_repo}"; \
41+
git clone --recursive "${module_repo}"; \
4242
cd ${dirname}; \
4343
git fetch --tags; \
4444
if [ -n "${module_tag}" ]; then \
@@ -108,6 +108,7 @@ RUN set -x \
108108
unzip \
109109
vim-tiny \
110110
libmaxminddb0 \
111+
libbrotli1 \
111112
&& apt-get clean \
112113
&& rm -rf /var/lib/apt/lists/* \
113114
&& ldconfig -v \

flavors.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"https://github.com/vozlt/nginx-module-vts.git:v0.2.1",
1515
"https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git",
1616
"https://github.com/leev/ngx_http_geoip2_module:3.4",
17-
"https://github.com/wandenberg/nginx-sorted-querystring-module.git"
17+
"https://github.com/wandenberg/nginx-sorted-querystring-module.git",
18+
"https://github.com/google/ngx_brotli.git:a71f9312c2deb28875acc7bacfdd5695a111aa53"
1819
],
1920
"lua_modules": [
2021
"tsuru-rpaasv2 INOTIFY_INCDIR=/usr/include/linux-gnu",

test/nginx-tsuru.bash

+9
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@ test_lua_http_resty() {
2929
assert '{"body":"nginx config check ok\n","proxied":true}' "$response" "/lua_http_resty with expected response"
3030
}
3131

32+
test_brotli() {
33+
response=$(curl --fail --silent --show-error localhost:8080/brotli)
34+
assert '<b>Brotli page</b>' "$response" "/brotli without compression response"
35+
36+
response=$(curl --fail --silent --show-error -H 'Accept-Encoding: br' localhost:8080/brotli | base64)
37+
assert 'BQmAPGI+QnJvdGxpIHBhZ2U8L2I+CgM=' "$response" "/brotli with brotli compression response"
38+
}
39+
3240
echo "Running tests"
3341

3442
test_nginx_serving_request
3543
test_lua_content
3644
test_lua_http_resty
45+
test_brotli
3746

3847
echo "✅ SUCESS: All tests passed"

test/nginx-tsuru.conf

+7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ http {
7979
}
8080
}
8181

82+
location /brotli {
83+
brotli on;
84+
default_type 'text/html';
85+
brotli_types text/html text/plain;
86+
echo '<b>Brotli page</b>';
87+
}
88+
8289
location ~ ^/purge/(.+) {
8390
proxy_cache_purge cache_zone $1$is_args$args;
8491
}

0 commit comments

Comments
 (0)