Signing a URL
imgproxy allows you to sign your URLs with a key and salt, so an attacker won’t be able to perform a denial-of-service attack by requesting multiple different image resizes.
Configuring URL signature​
URL signature checking is disabled by default, but it is highly recommended to enable it in a production environment. To do so, define a key/salt pair by setting the following environment variables:
IMGPROXY_KEY: hex-encoded keyIMGPROXY_SALT: hex-encoded salt
Read our Configuration guide to learn more ways of setting keys and salts.
If you need a random key/salt pair in a hurry, you can quickly generate one using the following snippet:
echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
Calculating URL signature​
A signature is a URL-safe Base64-encoded HMAC digest of the rest of the path, including the leading /. Here’s how it’s calculated:
- Take the part of the path after the signature:
- For processing URLs:
/%processing_options/%encoded_url.%extension,/%processing_options/plain/%plain_url@%extension, or/%processing_options/enc/%encrypted_url.%extension - For info URLs:
/%info_options/%encoded_url,/%info_options/plain/%plain_url, or/%info_options/enc/%encrypted_url
- For processing URLs:
- Add a salt to the beginning.
- Calculate the HMAC digest using SHA256.
- Encode the result with URL-safe Base64.