allow resize for uncached images

This commit is contained in:
sheepish committed 2026-03-09 14:56:22 +00:00
1 parent 51c192996b
commit 7790ad261d
3 files changed
+7 -6

No files matched your search

+1 -2
View File
@@ -44,8 +44,7 @@ HMAC result is truncated to 12 bytes, producing a 16 characters encoded signatur
`ext_url` is the result of `urlsafe-base64(image_url)`. Trailing `=` may be stripped.
`extension` is either the empty string or the string `/proxy` which instructs
the imageproxy server to not permanently store the source image. Resizing is
not supported in proxy-only mode.
the imageproxy server to not permanently store the source image.
## Signature test vector
+3 -2
View File
@@ -145,15 +145,16 @@ async def handle_signed_request(request: Request) -> Response:
is_proxy = len(url) == 4 and url[3] == 'proxy'
try:
imgproxy_opts = [] if is_proxy else parse_imgproxy_params(url[0])
imgproxy_opts = parse_imgproxy_params(url[0])
except BadOptions:
logger.debug("invalid resize options: %s", url[0])
return bad_request()
is_resize = bool(imgproxy_opts)
if not is_proxy:
imgproxy_opts.append(b'fn:' + img_url)
img_path = create_filename(bucket, img_url)
imgproxy_opts.append(b'fn:' + img_url)
# download and perma-store image through imgproxy
base_path = request.get_first_header(b'root_dir').decode('ascii')
+3 -2
View File
@@ -53,15 +53,16 @@ server {
set $img_url $upstream_http_imgproxy_url;
add_header Content-Type "";
add_header x-original-url $upstream_http_x_original_url;
rewrite .* /$loc_prefix/${imgproxy_opts}plain/local:///${img_path};
rewrite .* /${loc_prefix}/${imgproxy_opts}plain/local:///${img_path};
}
location @serve-imgproxy-remote {
# for non-cached images
set $imgproxy_opts $imgproxy_opts/$upstream_http_imgproxy_opts;
set $img_url $upstream_http_imgproxy_url;
add_header Content-Type "";
add_header x-original-url $upstream_http_x_original_url;
rewrite .* /$loc_prefix/${img_url};
rewrite .* /${loc_prefix}/${imgproxy_opts}/${img_url};
}
location @serve-proxy {