Static brotli/gzip and reverse proxy config question

This thread shows an example of how to do it. It’s a bit complicated because you need to do rewrites and set headers based on whether a pre-compressed file exists on disk.

We’re tracking support for content negotiation in the following github issue. There’s a lot of design work and consideration that needs to be done to implement it correctly. It’s definitely something we want to get in eventually.

Finally just as a quick note, you can replace handle + uri strip_prefix with just handle_path, it has path prefix stripping logic built in.

Also, I recommend using the root directive rather than the subdirective to file_server, that way the root will be set for all directives in your handle (will be necessary since the file matcher also needs to know the root to work)

handle_path /_next/static/* {
	root * /home/xyz/nextjs-built-project/.next/static

	# Precompress rewrites goes here

	file_server
}
1 Like