Skip to main content

Using configuration file with fl proxy

There are scenarios when defining fl proxy configuration with a configuration file is preferable to using command line options or environment variables. Configuration file is the only way to specify multiple virtual endpoints allowing multiple HMAC keys for incoming requests.

The config file name can be specified as a command line parameter for Flexify Engine.

fl proxy --config-file config.json

or

docker run --rm \
-p 80:80 \
-v $(pwd)/config.json:/etc/flexify/config.json \
flexifyio/proxy --config-file /etc/flexify/config.json

Configuration file format​

The configuration file must be properly formatted JSON with tasks definitions similar to those returned by the management server.

{
"virtualEndpoints": [
{
"credentials": {
"accessKey": "<Incoming S3 access key>",
"secretKey": "<Incoming S3 secret key>"
},
"serviceEndpoint": "s3.example.com",
"selectionPolicy": "NEWEST/FASTEST/PRIORITY",
"noputPolicy": "KEEP/REMOVE",
"putMinimum": 0,
"selectionBreakTimeout": 300,
"aes256KeyForKey": "dbBkkIzAhOizoZhpUdp2HcDhbO/0XKrAkrixy6JaIfM=",
"clouds": [
{
"cloud": {
"code": "AWS/AZURE/etc.",
"credentials": {
"accessKey": "<S3 access key or Azure storage account name>",
"secretKey": "<S3 secret key or Azure storage account key>"
},
"customEndpoint": null,
"customDefaultRegion": null,
"useSsl": true,
"forcePathStyle": false,
"bucketDotEncodeSequence": "-fldot-",
},
"noput": false,
"nodelete": false,
"createNewBucketsIn": "us-west-2"
},
...
],
"virtualBuckets": [
{
"bucketName": "my-virtual-bucket",
"storages": [
{
"storage": {
"cloud": {
"code": "AWS/AZURE/etc.",
"credentials": {
"accessKey": "<S3 access key or Azure storage account name>",
"secretKey": "<S3 secret key or Azure storage account key>"
},
"customEndpoint": null,
"useSsl": true,
"forcePathStyle": false,
"bucketDotEncodeSequence": null,

},
"bucket": "my-cloud-bucket-or-container-bame",
"region": "us-west-2"
},
"noput": false,
"nodelete": false
},
...
]
},
...
]
}
],
...
}

Full list of configuration file options can be found at the fl proxy page.

Environment variables substitute​

For some fields, mostly secrets, it is possible to specify environment variable name in ${ENV_VARIABLE} format instead of the field value. For example:

"credentials": {
"accessKey": "${MY_ACCESS_KEY_ID}",
"secretKey": "${MY_SECRET_KEY}"
}

The following fields support substitutes:

  • accessKey

  • secretKey

  • sessionToken

Configuration file examples​

You can run any of those examples by specifying the --config-file option:

fl proxy -c --port 8080 --config-file example.json

Example 1: Simple proxy to Azure​

This example have single virtual endpoint proxying S3 requests to Azure.

{
"virtualEndpoints": [
{
"credentials": {
"accessKey": "FlIO48KMFnVg09wM2DN4yBVI",
"secretKey": "wQZ.....QTR"
},
"aes256KeyForKey": "dbBkkIzAhOizoZhpUdp2HcDhbO/0XKrAkrixy6JaIfM=",
"clouds": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure storage account key>"
}
}
}
]
}
]
}

Example 2: Multiple virtual endpoints​

This example configures three virtual endpoints with different S3 credentials proxying to different Azure containers.

{
"virtualEndpoints": [
{
"credentials": {
"accessKey": "FlIO48KMFnVg09wM2DN4yBVI",
"secretKey": "wQZ.........2pQTR"
},
"aes256KeyForKey": "dbBkkIzAhOizoZhpUdp2HcDhbO/0XKrAkrixy6JaIfM=",
"virtualBuckets": [
{
"bucketName": "bucket1",
"storages": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure storage account key>"
}
},
"bucket": "container1"
}
]
}
]
},
{
"credentials": {
"accessKey": "FlIO01MpMHuKeLkxZgf8Xi",
"secretKey": "pM6..................t4e2"
},
"aes256KeyForKey": "KNOlMb0EC2WyCpdORfiIBynp+D14sfNJl7vqat06F0s=",
"virtualBuckets": [
{
"bucketName": "bucket2",
"storages": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure storage account key>"
}
},
"bucket": "container2"
}
]
}
]
},
{
"credentials": {
"accessKey": "FlIOY6zJpGCR1CnU8c9E32m",
"secretKey": "vx4.................FEa"
},
"aes256KeyForKey": "C3/BUQpmKv/rBB/GSfp77lJPHGadivon8TQHJWI593U=",
"virtualBuckets": [
{
"bucketName": "bucket3",
"storages": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure storage account key>"
}
},
"bucket": "container3"
}
]
}
]
}
]
}

Example 3: Multi-cloud between Azure and AWS​

This example configures single virtual endpoint that have both Azure container and Amazon S3 bucket attached, with priority selection policy: first check in Azure, only if an object not found - check in AWS.

{
"virtualEndpoints": [
{
"credentials": {
"accessKey": "FlIO48KMFnVg09wM2DN4yBVI",
"secretKey": "wQZ.................TR"
},
"selectionPolicy": "PRIORITY",
"aes256KeyForKey": "dbBkkIzAhOizoZhpUdp2HcDhbO/0XKrAkrixy6JaIfM=",
"clouds": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure storage account key>"
}
}
},
{
"cloud": {
"code": "AWS",
"credentials": {
"accessKey": "<S3 access key ID>",
"secretKey": "<S3 secret key>"
}
}
}
]
}
]
}

Example 4: Simple proxy to Azure using SAS Token​

This example uses Azure SAS token instead of Azure storage account key. By default "secretKeyType": "SECRET_ACCESS_KEY"

{
"virtualEndpoints": [
{
"credentials": {
"accessKey": "FlEoByJPFL2QCeUr1IDrIlA",
"secretKey": "NR.................At"
},
"aes256KeyForKey": "dbBkkIzAhOizoZhpUdp2HcDhbO/0XKrAkrixy6JaIfM=",
"clouds": [
{
"cloud": {
"code": "AZURE",
"credentials": {
"accessKey": "<Azure storage account name>",
"secretKey": "<Azure SAS token>",
"secretKeyType": "SHARED_ACCESS_SIGNATURE"
}
}
}
]
}
]
}