Set up Cloudflare R2
Configure a Cloudflare R2 bucket as the object store for LFS Harbor. R2 is S3-compatible and charges no egress fees, which makes it a good fit for LFS traffic.
Prerequisites — a Cloudflare account with R2 enabled. For the CLI steps, You'll also need your Cloudflare Account ID, shown on the R2 overview page in the dashboard. The R2 S3 endpoint is
wrangler is installed and authenticated:bash
wrangler loginhttps://ACCOUNT_ID.r2.cloudflarestorage.com.1
Create a bucket
Pick a jurisdiction based on where your data needs to live. Automatic lets Cloudflare place objects close to the first writer and is the right default for most setups.
- 1. Open the Cloudflare dashboard, go to R2 Object Storage, and click Create bucket.
- 2. Enter a bucket name and leave the location at
Automatic. - 3. Click Create bucket.
2
Create an R2 API token
R2 API tokens bundle the permission scope and the S3 credentials into one step. Scope the token to this bucket and to Object Read & Write only — LFS Harbor does not need any admin-level permissions.
- 1. From R2 Object Storage, under Account Details select Manage and click Create Account API token.
- 2. Name the token
LFS Harbor storage. Under Permissions, select Object Read & Write. - 3. Under Specify bucket(s), choose Apply to specific buckets only and select the bucket you just created. Leave TTL and IP restrictions blank unless you have a reason to set them.
- 4. Click Create API Token. Copy the Access Key ID and Secret Access Key shown on the next screen. The secret is only displayed once.
Keep these credentials secret. Don't commit them to version control. If they're ever exposed, revoke the token in R2 Object Storage → Manage R2 API tokens and create a new one.
3
Add the credentials to LFS Harbor
Connect your R2 bucket to LFS Harbor through the dashboard.
- 1. Go to the LFS Harbor dashboard.
- 2. Click on your repository.
- 3. Edit the object store configuration.
- 4. Choose S3-compatible as the storage provider. R2 uses LFS Harbor's S3-compatible connection.
- 5. Enter your bucket name and set the endpoint to
https://ACCOUNT_ID.r2.cloudflarestorage.com, replacingACCOUNT_IDwith your Cloudflare account ID. Set the region toauto. - 6. Enter the access key ID and secret access key.
4
Set up LFS Harbor as your Git LFS server
Choose the guide that fits your situation:
- Add Git LFS to a repository — for repos that don't use Git LFS yet.
- Migrate from another provider — for repos already using a different Git LFS server.