Le 31/03/2025 à 1:46 PM, Olivier D a écrit :
Hello, thanks for the quick reply !

Le lun. 31 mars 2025 à 10:35, Willy Tarreau <w...@1wt.eu <mailto:w...@1wt.eu>> 
a écrit :

       Compression is disabled when:
         * the request does not advertise a supported compression algorithm in 
the
           "Accept-Encoding" header
         * the response message is not HTTP/1.1 or above
         * HTTP status code is not one of 200, 201, 202, or 203
         * response contain neither a "Content-Length" header nor a
           "Transfer-Encoding" whose last value is "chunked"
         * response contains a "Content-Type" header whose first value starts 
with
           "multipart"
         * the response contains the "no-transform" value in the "Cache-control"
           header
         * User-Agent matches "Mozilla/4" unless it is MSIE 6 with XP SP2, or 
MSIE 7
           and later
         * The response contains a "Content-Encoding" header, indicating that 
the
           response is already compressed (see compression offload)
         * The response contains an invalid "ETag" header or multiple ETag 
headers
         * The payload size is smaller than the minimum size
           (see compression minsize-res)


I've already checked all these points. "minsize-res" was introduced in 3.2 I guess (and I'm using 3.1) but the default value being 0, it's not the issue here.

What I do :
  $ curl -v --http1.1 --compressed https://example.com/ <https://example.com/>
  GET / HTTP/1.1
  Host: example.com <http://example.com>
  User-Agent: curl/7.76.1
  Accept: */*
  Accept-Encoding: deflate, gzip

  HTTP/1.1 200 OK
  x-version: 20250331.2
  cache-control: private, no-cache, no-store, max-age=0
  content-type: text/html
  content-length: 3362

No compression here :(

HAProxy config snippet :
backend test
[...]
   filter compression
   compression algo-res gzip
   compression type-res text/html
  acl static_content path_end .png .gif .css .js .svg .jpg .jpeg .ico .woff .woff2 .ttf .eot .otf .webp .pdf .webp .webm .weba
   http-request lua.myscript if !static_content


If you have any clue, I'll be glad to perform more tests.

Olivier

Hi Olivier,

In fact, in your case, it is expected to have no compression. You abort the request analysis, skipping this way the response analysis. It is equivalent to what happens with an "http-request deny". The compression is performed during the response analysis.

To be able to compress a response returned from a lua script, you must use a service instead of an action that aborts the request. A lua service is an applet that is equivalent to a server. So the response analysis is performed and the response is no limited to one buffer. To do so, you must use the "use-service" action.

--
Christopher Faulet



Reply via email to