apisix
apisix copied to clipboard
bug: The gzip plugin does not work in special scenarios
Current Behavior
- Openresty as the upstream, the configuration file is as follows
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
server {
listen 8866;
location / {
content_by_lua '
ngx.say("hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world.")
';
}
}
}
- enable the proxy-rewrite plugin,config as follow
"gzip": {
"buffers": {
"number": 64,
"size": 4096
},
"comp_level": 5,
"disable": false,
"min_length": 200,
"types": "*",
"vary": true
}
- send a request without a via header
curl http://127.0.0.1:9080/test_gzip -H 'accept-encoding: gzip' -i
- output
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Date: Thu, 02 Mar 2023 12:33:53 GMT
Server: Openresty
Vary: Accept-Encoding
Content-Encoding: gzip
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.
- send a request with a via header
curl http://127.0.0.1:9080/test_gzip -H 'accept-encoding: gzip' -i -H 'via: aaa'
- output
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Date: Thu, 02 Mar 2023 12:36:11 GMT
Server: Openresty
Vary: Accept-Encoding
hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world. hello, world.
Expected Behavior
The compression behavior of apisix should not be affected by the via header
Error Logs
none
Steps to Reproduce
Same as above
Environment
- APISIX version (run
apisix version): 2.10.5 - Operating system (run
uname -a): amzn2.x86_64 - OpenResty / Nginx version (run
openresty -Vornginx -V): openresty/1.19.9.1 - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info): 3.5 - APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run
luarocks --version):
2.10.5 is too old. Try the latest version to see if the gzip plugin works.
It is Nginx itself that disables the gzip, see code https://github.com/nginx/nginx/blob/4ace957c4e08bcbf9ef5e9f83b8e43458bead77f/src/http/ngx_http_core_module.c#L2071-L2159 and configuration: http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_proxied APISIX so far doesn't have option to override this behavior.
Or we can override it via custom Nginx conf: https://github.com/apache/apisix/blob/master/docs/en/latest/customize-nginx-configuration.md
Or we can override it via custom Nginx conf: https://github.com/apache/apisix/blob/master/docs/en/latest/customize-nginx-configuration.md
Got it. Thank you for your reply. Maybe we can provide an option to reset via header in gzip plugin ? @spacewander
PR is welcome!
PR is welcome!
OK
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.