Tuesday, November 29, 2022

gzip-static for website root directory

I have a basic web server set up

server "example.com" {
listen on * port 80
gzip-static

directory {
index index.html
no auto index
}
}

When opening the root webpage (http://example.com), the server does not
respond with "Content-Encoding: gzip" and does not use the gzipped
index file from the directory index (index.html). The gzip encoded
file is returned for sub-directories (http://example.com/mypage/). As a
fix I am using

location match "^/$" {
block return 307 "/index.html"
}

I tried "request rewrite" instead of "block return" but it didn't work.
Is this as intended, or is there a better way to have the gzip
encoded file delivered for the webpage root?

No comments:

Post a Comment