-
Notifications
You must be signed in to change notification settings - Fork 26
Nginx: brotli support #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fcae762
Placeholders required for add Brotli support were added.
0xbxmb d6bcb9b
Brotli configuration was added.
0xbxmb d857d9c
Merge branch 'master' into feat-nginx-br-support
0xbxmb 586ddb8
Merge branch 'master' into feat-nginx-br-support
0xbxmb 54e03f3
Update Dockerfile
0xbxmb ca1521a
The version was fixed.
0xbxmb 1a8764f
feat(ETHOS-39682): Add goss and basic tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥