apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: The gzip plugin does not work in special scenarios

Open zuiyangqingzhou opened this issue 2 years ago • 7 comments
trafficstars

Current Behavior

  1. 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.")
	    ';
        }
    }
}
  1. 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
    }
  1. 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.
  1. 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 -V or nginx -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):

zuiyangqingzhou avatar Mar 02 '23 12:03 zuiyangqingzhou

2.10.5 is too old. Try the latest version to see if the gzip plugin works.

tokers avatar Mar 03 '23 01:03 tokers

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.

spacewander avatar Mar 03 '23 02:03 spacewander

Or we can override it via custom Nginx conf: https://github.com/apache/apisix/blob/master/docs/en/latest/customize-nginx-configuration.md

spacewander avatar Mar 03 '23 02:03 spacewander

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

zuiyangqingzhou avatar Mar 03 '23 03:03 zuiyangqingzhou

PR is welcome!

spacewander avatar Mar 05 '23 12:03 spacewander

PR is welcome!

OK

zuiyangqingzhou avatar Mar 06 '23 02:03 zuiyangqingzhou

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.

github-actions[bot] avatar Feb 19 '24 10:02 github-actions[bot]

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.

github-actions[bot] avatar Mar 04 '24 10:03 github-actions[bot]