-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from bombinmybag/feat-nginx-br-support
Nginx: brotli support
- Loading branch information
Showing
11 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
file: | ||
/etc/nginx/nginx.conf: | ||
exists: true | ||
# By default, the brotli configs are specified in nginx.conf but disabled | ||
contains: | ||
- '/#load_module\s*modules\/ngx_http_brotli_filter_module\.so;/' | ||
- '/#load_module\s*modules\/ngx_http_brotli_static_module\.so;/' | ||
- '/#brotli\s*on;/' | ||
- '/#brotli_static\s*on;/' | ||
- '/#brotli_comp_level\s*6;/' | ||
- '/#brotli_types/' | ||
title: /etc/nginx/nginx.conf should exist and contain brotli-specific configs | ||
/usr/lib/nginx/modules/ngx_http_brotli_filter_module.so: | ||
exists: true | ||
owner: root | ||
title: /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so should exist and owned by root | ||
/usr/lib/nginx/modules/ngx_http_brotli_static_module.so: | ||
exists: true | ||
owner: root | ||
title: /usr/lib/nginx/modules/ngx_http_brotli_static_module.so should exist and owned by root |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM docker-nginx:brotli |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.PHONY: build | ||
|
||
# Name of the image to build | ||
IMAGE_TAG=docker-nginx:brotli | ||
|
||
default: build | ||
|
||
build-src: | ||
cd ../.. && docker build -t $(IMAGE_TAG) -f Dockerfile . | ||
|
||
build: build-src | ||
docker build -t $(IMAGE_TAG)-test -f Dockerfile . | ||
|
||
dgoss: build | ||
GOSS_WAIT_OPTS="-r 60s -s 5s > /dev/null" dgoss run -e SERVER_ENABLE_NGX_BROTLI=true -p 8080:8080 $(IMAGE_TAG)-test | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
brotli | ||
==== | ||
|
||
This is a simple [dgoss] test to validate that the brotli module is running. | ||
|
||
To test: | ||
|
||
1. cd `tests/brotli` | ||
1. Run `make dgoss` | ||
|
||
Behind the scenes, it builds the `brotli`-enabled docker image, then builds | ||
a test image. | ||
|
||
Finally, it runs `dgoss` and passes in `Accept-Encoding: gzip, deflate, br` | ||
as part of the request. | ||
|
||
Here's a sample curl request when `SERVER_ENABLE_NGX_BROTLI=true`: | ||
|
||
```shell | ||
$ curl http://localhost:8080/ -v -H "Accept-Encoding: gzip, deflate, br" | ||
* Trying ::1... | ||
* TCP_NODELAY set | ||
* Connected to localhost (::1) port 8083 (#0) | ||
> GET / HTTP/1.1 | ||
> Host: localhost:8080 | ||
> User-Agent: curl/7.64.1 | ||
> Accept: */* | ||
> Accept-Encoding: gzip, deflate, br | ||
> | ||
< HTTP/1.1 200 OK | ||
< Server: nginx | ||
< Date: Wed, 17 Aug 2022 21:41:21 GMT | ||
< Content-Type: text/html | ||
< Last-Modified: Wed, 17 Aug 2022 17:59:04 GMT | ||
< Transfer-Encoding: chunked | ||
< Connection: keep-alive | ||
< ETag: W/"62fd2c68-279" | ||
< X-XSS-Protection: 1; mode=block | ||
< X-Content-Type-Options: nosniff | ||
< Content-Encoding: br | ||
< | ||
Warning: Binary output can mess up your terminal. Use "--output -" to tell | ||
Warning: curl to output it to your terminal anyway, or consider "--output | ||
Warning: <FILE>" to save to a file. | ||
* Failed writing body (0 != 299) | ||
* Failed writing data | ||
* Closing connection 0 | ||
``` | ||
The script assumes that you have `dgoss` installed. | ||
[dgoss]: https://github.com/aelsabbahy/goss/blob/master/extras/dgoss/README.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
file: | ||
/etc/nginx/nginx.conf: | ||
exists: true | ||
contains: | ||
- '/load_module\s*modules\/ngx_http_brotli_filter_module\.so;/' | ||
- '/load_module\s*modules\/ngx_http_brotli_static_module\.so;/' | ||
- '/brotli\s*on;/' | ||
- '/brotli_static\s*on;/' | ||
- '/brotli_comp_level\s*6;/' | ||
- '/brotli_types/' | ||
title: brotli-specific modules and configs should be enabled | ||
http: | ||
http://localhost:8080/: | ||
status: 200 | ||
allow-insecure: true | ||
request-headers: | ||
- "Accept-Encoding: gzip, deflate, br" | ||
timeout: 5000 | ||
headers: | ||
# When you pass in the Accept-Encoding header | ||
# the response header will include "Content-Encoding: br" | ||
# and the output will be compressed/binary | ||
- "Content-Encoding: br" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
file: | ||
/goss/docker_output.log: | ||
exists: true | ||
contains: | ||
# When starting up the container, this line should show up | ||
# if SERVER_ENABLE_NGX_BROTLI=true | ||
- '[nginx] enabling nginx brotli module' |