Skip to content
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

bug: The gzip plugin does not work in special scenarios #8995

Closed
zuiyangqingzhou opened this issue Mar 2, 2023 · 8 comments
Closed

bug: The gzip plugin does not work in special scenarios #8995

zuiyangqingzhou opened this issue Mar 2, 2023 · 8 comments
Labels

Comments

@zuiyangqingzhou
Copy link
Contributor

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):
@tokers
Copy link
Contributor

tokers commented Mar 3, 2023

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

@spacewander
Copy link
Member

spacewander commented Mar 3, 2023

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
Copy link
Member

@zuiyangqingzhou
Copy link
Contributor Author

zuiyangqingzhou commented Mar 3, 2023

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

@spacewander
Copy link
Member

PR is welcome!

@zuiyangqingzhou
Copy link
Contributor Author

PR is welcome!

OK

Copy link

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 dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 19, 2024
Copy link

github-actions bot commented Mar 4, 2024

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants