On Thursday, March 23rd, 2023 at 2:15 PM, Jordan Geoghegan 
<jor...@geoghegan.ca> wrote:


> 
> On 3/9/23 17:31, Joel Carnat wrote:
> 
> > 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.
> 
> 
> Can confirm - I recently stumbled over this confusing behaviour as well.
> Curious if this is a bug or a man page issue.
> 
> Regards,
> 
> Jordan

On my server (7.2 amd64) I have gzip-static set in the server block as 
documented, and it appears to work as expected. I am sorry that it probably 
doesn't help your situation, but maybe the differences in configuration can 
help point you in the right direction?

-- config --

server "hrpr.us" {
        listen on * port 80
        location "/.well-known/acme-challenge/*" {
                root "/acme"
                request strip 2
        }
        location * {
                block return 302 "https://$HTTP_HOST$REQUEST_URI";
        }
}

server "hrpr.us" {
        listen on * tls port 443
        alias www.hrpr.us
        gzip-static
        tls {
                certificate "/etc/ssl/hrpr.us.fullchain.pem"
                key "/etc/ssl/private/hrpr.us.key"
        }
        location "/pub/*" {
                directory auto index
        }
        location "/.well-known/acme-challenge/*" {
                root "/acme"
                request strip 2
        }
        root "/htdocs/hrpr.us/"
}

-- curl results --
~% curl -I --compressed https://hrpr.us
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 749
Content-Type: text/html
Date: Thu, 23 Mar 2023 21:18:20 GMT
Last-Modified: Thu, 23 Mar 2023 20:49:21 GMT
Server: OpenBSD httpd

~% curl -I https://hrpr.us             
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1531
Content-Type: text/html
Date: Thu, 23 Mar 2023 21:18:23 GMT
Last-Modified: Thu, 23 Mar 2023 20:49:21 GMT
Server: OpenBSD httpd

Reply via email to