Hi,

I just tried applying gzip compression on a simple test web site using httpd and the gzip-static option ; using OpenBSD 7.2/amd64.

As I understood the man page, gzip-static is supposed to be used inside the server block ; like listen, errdocs or tls. But doing so does not seem to enable gzip compression for files defined in a location block.

What fails:
server "default" {
  listen on 127.0.0.1 port 80
  gzip-static
  block drop
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
    pass
  }
  location "/www/*" {
    root "/test"
    request strip 1
    pass
  }
}

What works:
server "default" {
  listen on 127.0.0.1 port 80
  block drop
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
    pass
  }
  location "/www/*" {
    gzip-static
    root "/test"
    request strip 1
    pass
  }
}

As you may see, what works is using gzip-static inside a location block and not outside. I've tested is using Firefox, curl and https://gtmetrix.com. All confirm gzip-static must be inside the location block to provide compressed resources.

Here's an example of the curl command I used:
# curl -I --compressed http://localhost:80/www/index.html
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 1083
Content-Type: text/html
Date: Fri, 10 Mar 2023 01:27:53 GMT
Last-Modified: Fri, 10 Mar 2023 00:53:26 GMT
Server: OpenBSD httpd

Is this an expected behaviour?

Regards,
Joel C.

Reply via email to