imgproxy can load environment variables from various sources such as:
You can create an environment file and configure imgproxy to read environment variables from it.
IMGPROXY_ENV_LOCAL_FILE_PATH
: the path of the environmebt file to loadYou can store the content of an environment file as an AWS Secrets Manager secret and configure imgproxy to read environment variables from it.
IMGPROXY_ENV_AWS_SECRET_ID
: the ARN or name of the secret to loadIMGPROXY_ENV_AWS_SECRET_VERSION_ID
: (optional) the unique identifier of the version of the secret to loadIMGPROXY_ENV_AWS_SECRET_VERSION_STAGE
: (optional) the staging label of the version of the secret to loadIMGPROXY_ENV_AWS_SECRET_REGION
: (optional) the region of the secret to load📝 Note: If both IMGPROXY_ENV_AWS_SECRET_VERSION_ID
and IMGPROXY_ENV_AWS_SECRET_VERSION_STAGE
are set, IMGPROXY_ENV_AWS_SECRET_VERSION_STAGE
will be ignored
There are three ways to specify your AWS credentials. The credentials policy should allow performing the secretsmanager:GetSecretValue
and secretsmanager:ListSecretVersionIds
actions with the specified secret:
If you're running imgproxy on an Amazon Web Services platform, you can use IAM roles to to get the security credentials to retrieve the secret.
You can specify an AWS Access Key ID and a Secret Access Key by setting the standard AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables.
AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy
# same for Docker
docker run -e AWS_ACCESS_KEY_ID=my_access_key -e AWS_SECRET_ACCESS_KEY=my_secret_key -it darthsim/imgproxy
Alternatively, you can create the .aws/credentials
file in your home directory with the following content:
[default]
aws_access_key_id = %access_key_id
aws_secret_access_key = %secret_access_key
You can store multiple AWS Systems Manager Parameter Store entries and configure imgproxy to load their values to separate environment variables.
IMGPROXY_ENV_AWS_SSM_PARAMETERS_PATH
: the path of the parameters to loadIMGPROXY_ENV_AWS_SSM_PARAMETERS_REGION
: (optional) the region of the parameters to loadLet's assume that you created the following AWS Systems Manager parameters:
/imgproxy/prod/IMGPROXY_KEY
/imgproxy/prod/IMGPROXY_SALT
/imgproxy/prod/IMGPROXY_CLOUD_WATCH/SERVICE_NAME
/imgproxy/prod/IMGPROXY_CLOUD_WATCH/NAMESPACE
/imgproxy/staging/IMGPROXY_KEY
If you set IMGPROXY_ENV_AWS_SSM_PARAMETERS_PATH
to /imgproxy/prod
, imgproxy will load these parameters the following way:
/imgproxy/prod/IMGPROXY_KEY
value will be loaded to IMGPROXY_KEY
/imgproxy/prod/IMGPROXY_SALT
value will be loaded to IMGPROXY_SALT
/imgproxy/prod/IMGPROXY_CLOUD_WATCH/SERVICE_NAME
value will be loaded to IMGPROXY_CLOUD_WATCH_SERVICE_NAME
/imgproxy/prod/IMGPROXY_CLOUD_WATCH/NAMESPACE
value will be loaded to IMGPROXY_CLOUD_WATCH_NAMESPACE
/imgproxy/staging/IMGPROXY_KEY
will be ignored since its path is not /imgproxy/prod
There are three ways to specify your AWS credentials. The credentials policy should allow performing the ssm:GetParametersByPath
action with the specified parameters:
If you're running imgproxy on an Amazon Web Services platform, you can use IAM roles to to get the security credentials to retrieve the secret.
You can specify an AWS Access Key ID and a Secret Access Key by setting the standard AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables.
AWS_ACCESS_KEY_ID=my_access_key AWS_SECRET_ACCESS_KEY=my_secret_key imgproxy
# same for Docker
docker run -e AWS_ACCESS_KEY_ID=my_access_key -e AWS_SECRET_ACCESS_KEY=my_secret_key -it darthsim/imgproxy
Alternatively, you can create the .aws/credentials
file in your home directory with the following content:
[default]
aws_access_key_id = %access_key_id
aws_secret_access_key = %secret_access_key
You can store the content of an environment file in Google Cloud Secret Manager secret and configure imgproxy to read environment variables from it.
IMGPROXY_ENV_GCP_SECRET_ID
: the name of the secret to loadIMGPROXY_ENV_GCP_SECRET_VERSION_ID
: (optional) the unique identifier of the version of the secret to loadIMGPROXY_ENV_GCP_SECRET_PROJECT_ID
: the name or ID of the Google Cloud project that contains the secretIf you run imgproxy inside Google Cloud infrastructure (Compute Engine, Kubernetes Engine, App Engine, Cloud Functions, etc), and you have granted access to the specified secret to the service account, you probably don't need to do anything here. imgproxy will try to use the credentials provided by Google.
Otherwise, set IMGPROXY_ENV_GCP_KEY
environment variable to the content of Google Cloud JSON key. Get more info about JSON keys: https://cloud.google.com/iam/docs/creating-managing-service-account-keys.
The following syntax rules apply to environment files:
#
are processed as comments and ignoredVAR=VAL
-> VAL
VAR="VAL"
-> VAL
VAR='VAL'
-> VAL
"
) values have variable substitution applied:
VAR=${OTHER_VAR}
-> value of OTHER_VAR
VAR=$OTHER_VAR
-> value of OTHER_VAR
VAR="$OTHER_VAR"
-> value of OTHER_VAR
VAR="${OTHER_VAR}"
-> value of OTHER_VAR
'
) values are used literally:
VAR='$OTHER_VAR'
-> $OTHER_VAR
VAR='${OTHER_VAR}'
-> ${OTHER_VAR}
"
) values can be escaped with \
:
VAR="{\"hello\": \"json\"}"
-> {"hello": "json"}
\
) in double-quoted values can be escaped with another slash:
VAR="some\\value"
-> some\value
A new line can be added to double-quoted values using \n
:
VAR="some\nvalue"
->
some
value