IMGPROXY_ENABLE_CLIENT_HINTS doesn't enable Client Hints support at all, on v4.0.12 and on master. Setting it to true has zero observable effect: imgproxy never sends the Vary header it's supposed to when the feature is active, and Width/DPR/Sec-CH-Width/Sec-CH-DPR request headers are silently ignored regardless of the URL's processing options.
Root cause
clientfeatures/config.go's LoadConfigFromEnv() never calls .Parse() for IMGPROXY_ENABLE_CLIENT_HINTS, even though the var is declared and every sibling flag in the same struct is correctly wired:
// clientfeatures/config.go
var (
IMGPROXY_AUTO_WEBP = env.Bool("IMGPROXY_AUTO_WEBP")
IMGPROXY_AUTO_AVIF = env.Bool("IMGPROXY_AUTO_AVIF")
IMGPROXY_AUTO_JXL = env.Bool("IMGPROXY_AUTO_JXL")
IMGPROXY_ENFORCE_WEBP = env.Bool("IMGPROXY_ENFORCE_WEBP")
IMGPROXY_ENFORCE_AVIF = env.Bool("IMGPROXY_ENFORCE_AVIF")
IMGPROXY_ENFORCE_JXL = env.Bool("IMGPROXY_ENFORCE_JXL")
IMGPROXY_ENABLE_CLIENT_HINTS = env.Bool("IMGPROXY_ENABLE_CLIENT_HINTS") // declared...
)
func LoadConfigFromEnv(c *Config) (*Config, error) {
c = ensure.Ensure(c, NewDefaultConfig)
err := errors.Join(
IMGPROXY_AUTO_WEBP.Parse(&c.AutoWebp),
IMGPROXY_ENFORCE_WEBP.Parse(&c.EnforceWebp),
IMGPROXY_AUTO_AVIF.Parse(&c.AutoAvif),
IMGPROXY_ENFORCE_AVIF.Parse(&c.EnforceAvif),
IMGPROXY_AUTO_JXL.Parse(&c.AutoJxl),
IMGPROXY_ENFORCE_JXL.Parse(&c.EnforceJxl),
// ...but never parsed here, unlike every other flag above.
)
return c, err
}
Since c.EnableClientHints stays at its zero value (false), Detector.Features() (clientfeatures/detector.go) returns immediately without ever checking any Client Hints header:
if !d.config.EnableClientHints {
return f
}
Reproduction (against the official image, no custom build):
docker run -d --name imgproxy-test -p 127.0.0.1:8091:8080 \
-e IMGPROXY_ENABLE_CLIENT_HINTS=true \
ghcr.io/imgproxy/imgproxy:v4.0.12
SRC="https://raw.githubusercontent.com/WordPress/wordpress-develop/trunk/tests/phpunit/data/images/canola.jpg"
# No Vary header in the response, and identical output with or without a Width header:
curl -sSI "http://127.0.0.1:8091/insecure/rt:fit/plain/$SRC"
curl -sSI -H "Width: 200" "http://127.0.0.1:8091/insecure/rt:fit/plain/$SRC"
# both: Content-Length: 59187, no Vary header
# Confirms resizing itself works fine — explicit width is fully respected:
curl -sSI "http://127.0.0.1:8091/insecure/resize:fit:200:0/plain/$SRC"
# Content-Length: 5969
Expected: with IMGPROXY_ENABLE_CLIENT_HINTS=true, a request with a Width: 200 header and no explicit width in the URL should be resized accordingly, and the response should carry a Vary: Sec-Ch-Dpr, Dpr, Sec-Ch-Width, Width header.
Actual: the Width header is silently ignored and no Vary header is ever sent, regardless of the env var's value.
Suggested fix: add the missing line to LoadConfigFromEnv:
IMGPROXY_ENABLE_CLIENT_HINTS.Parse(&c.EnableClientHints),
Version: v4.0.12 (also confirmed present on master as of this writing).
IMGPROXY_ENABLE_CLIENT_HINTSdoesn't enable Client Hints support at all, on v4.0.12 and onmaster. Setting it totruehas zero observable effect: imgproxy never sends theVaryheader it's supposed to when the feature is active, andWidth/DPR/Sec-CH-Width/Sec-CH-DPRrequest headers are silently ignored regardless of the URL's processing options.Root cause
clientfeatures/config.go'sLoadConfigFromEnv()never calls.Parse()forIMGPROXY_ENABLE_CLIENT_HINTS, even though the var is declared and every sibling flag in the same struct is correctly wired:Since
c.EnableClientHintsstays at its zero value (false),Detector.Features()(clientfeatures/detector.go) returns immediately without ever checking any Client Hints header:Reproduction (against the official image, no custom build):
Expected: with
IMGPROXY_ENABLE_CLIENT_HINTS=true, a request with aWidth: 200header and no explicit width in the URL should be resized accordingly, and the response should carry aVary: Sec-Ch-Dpr, Dpr, Sec-Ch-Width, Widthheader.Actual: the
Widthheader is silently ignored and noVaryheader is ever sent, regardless of the env var's value.Suggested fix: add the missing line to
LoadConfigFromEnv:Version: v4.0.12 (also confirmed present on
masteras of this writing).