Repository navigation
Configuration
Anchor LFS uses a TOML configuration file. Copy the example template to get started:
cp config.toml.example config.tomlThe server looks for config.toml in the current working directory by default. Name another file with --config <path> or the ANCHOR_LFS_CONFIG environment variable; the flag wins when both are set.
To validate a configuration without starting the server, run anchor-lfs check (with --config if needed). It prints the effective configuration, with defaults and environment overrides applied and secrets redacted, or lists every problem and exits 1, so it suits CI and checks before a restart.
The config file has three sections:
-
[options]: Global server settings -
[storage]: Storage backend configuration -
[[endpoints]]: Repository endpoint definitions (one or more)
[options]
listen_address = ":5420"
data_directory = "./data"
log_format = "json"
log_level = "info"
#access_log = true
#metrics_address = "127.0.0.1:9420"
#base_url = "https://lfs.example.com"
#trusted_proxies = ["127.0.0.0/8", "::1/128", "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "fc00::/7"]
#max_upload_size = 5368709120
#upload_idle_timeout = "60s"
#rate_limit_tokens = 600
#rate_limit_window = "1m"
#auth_cache_ttl = "60s"
#signing_key = ""
#url_expiry = "10m"
#shutdown_timeout = "30s"| Option | Type | Default | Description |
|---|---|---|---|
listen_address |
string | :5420 |
Address and port the server binds to. Use :5420 to listen on all interfaces, or 127.0.0.1:5420 to restrict to localhost. |
metrics_address |
string | (off) | Address and port that serve Prometheus metrics at GET /metrics, such as 127.0.0.1:9420. Must use a different port from listen_address. The metrics have no authentication, so bind them to loopback or a private network. |
data_directory |
string | ./data |
Path where local objects, lock state, and the signing key are stored. |
log_format |
string | json |
Log output format: json writes one JSON object per line to stderr, for log collectors; console writes human-readable lines, coloured only when stderr is a terminal. |
log_level |
string | info |
Lowest level logged: debug, info, warn or error. |
access_log |
bool | true |
Log every request with its method, path, status, duration in milliseconds, bytes sent and client IP. Requests are logged at info, client errors (4xx) at warn, server errors (5xx) at error, and successful /health and /ready checks at debug. |
additional_logging |
bool | false |
Deprecated: true is the same as log_format = "console" and log_level = "debug", unless those are set, and logs a warning at startup. |
base_url |
string | (derived from headers) | External base URL for transfer action hrefs (e.g., https://lfs.example.com). Recommended for production. If omitted, URLs are derived from the Host header, or from X-Forwarded-Proto and X-Forwarded-Host when a trusted proxy sends them. |
trusted_proxies |
list of IPs or CIDR ranges | loopback and private ranges | Peers allowed to set X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto. These headers are removed from requests sent by any other peer, so a client connecting directly cannot choose its rate-limit IP or the generated URLs. Set [] to trust no one. See Reverse Proxy. |
max_upload_size |
int64 |
5368709120 (5 GiB) |
Maximum allowed upload size in bytes. Uploads exceeding this are rejected during batch negotiation. |
upload_idle_timeout |
duration | 60s |
How long an upload may go without receiving any data before it is abandoned with 408 Request Timeout. Uploads can take as long as they need while data keeps arriving. Set to 0s to wait indefinitely. |
rate_limit_tokens |
uint64 | 600 |
Batch and lock requests each client IP may make per rate_limit_window. Object transfers are not counted. |
rate_limit_window |
duration | 1m |
Length of the fixed rate limit window. The full budget is restored when each window ends, and a limited client waits until then. Uses Go duration syntax (e.g., 30s, 1m, 1h). |
auth_cache_ttl |
duration | 60s |
How long GitHub authentication results are cached. Set to 0s to disable caching entirely. |
signing_key |
string (hex) | (auto-generated) | HMAC signing key for transfer URLs, hex-encoded. Minimum 32 bytes (64 hex characters). If omitted, a key is auto-generated and saved to <data_directory>/signing.key. Generate one with: openssl rand -hex 32
|
url_expiry |
duration | 10m |
How long signed transfer URLs remain valid. Uses Go duration syntax. |
shutdown_timeout |
duration | 30s |
How long a shutdown waits for in-flight requests to finish before closing their connections. Keep the stop grace period of Docker, systemd or Kubernetes longer than this; see Graceful Shutdown. |
Warning
Always set base_url in production. Without it, the server derives transfer URLs from X-Forwarded-Proto and X-Forwarded-Host request headers, which increases the attack surface. Only peers in trusted_proxies can set those headers, but a client on a trusted network could still influence the generated URLs. Setting base_url explicitly eliminates this risk entirely.
See Storage Backends for full details. Quick summary:
# Local filesystem (default; no [storage] block needed)
[storage]
backend = "local"
# S3-compatible storage
[storage]
backend = "s3"
s3_bucket = "my-lfs-bucket"
s3_region = "us-east-1"Each [[endpoints]] block defines a Git repository whose LFS objects are served. You can configure multiple endpoints on a single server instance.
[[endpoints]]
name = "My Repository"
url = "https://github.com/org/repo"
endpoint = "/org/repo"
visibility = "public"
authentication = "github"| Field | Required | Description |
|---|---|---|
name |
Yes | A human-readable name for the endpoint (used in logs). |
url |
Yes | The GitHub repository URL (e.g., https://github.com/org/repo). Must contain exactly org/repo in the path. |
endpoint |
Yes | The URL path prefix where this endpoint is served (e.g., /org/repo or /org/repo.js). Must start with / and have no trailing slash, empty segments (//), or dot segments (., ..). Segments may contain letters, digits, ., _ and -, and the path may not start with /. or end with .. Must be unique across all endpoints, including its storage directory name (the path without its leading slash, with / replaced by _, compared ignoring case). Cannot use the reserved paths /health, /ready, /locks and /signing.key. |
visibility |
Yes |
"public" or "private". Public endpoints allow anonymous downloads; private endpoints require authentication for all operations. |
authentication |
Yes |
"github" or "none". See Authentication for details. |
github_api_url |
No | GitHub Enterprise API URL (e.g., https://github.example.com/api/v3/). Required when the repository URL is not on github.com. Must use https, except on localhost and loopback addresses. Every client token for the endpoint is sent to this host. |
# Public open-source repo
[[endpoints]]
name = "Open Source Project"
url = "https://github.com/myorg/public-repo"
endpoint = "/myorg/public-repo"
visibility = "public"
authentication = "github"
# Private internal repo
[[endpoints]]
name = "Internal Assets"
url = "https://github.com/myorg/private-assets"
endpoint = "/myorg/private-assets"
visibility = "private"
authentication = "github"
# GitHub Enterprise repo
[[endpoints]]
name = "Enterprise Repo"
url = "https://github.example.com/team/project"
endpoint = "/team/project"
visibility = "private"
authentication = "github"
github_api_url = "https://github.example.com/api/v3/"
# Local development (no auth)
[[endpoints]]
name = "Local Dev"
url = "https://github.com/dev/test-repo"
endpoint = "/dev/test-repo"
visibility = "public"
authentication = "none"Every global option except the deprecated additional_logging, and every storage setting, can be overridden with an environment variable. Environment variables take precedence over values in the config file.
| Variable | Overrides |
|---|---|
ANCHOR_LFS_CONFIG |
Config file path (default: config.toml); --config takes precedence |
ANCHOR_LFS_LISTEN |
options.listen_address |
ANCHOR_LFS_METRICS_ADDRESS |
options.metrics_address |
ANCHOR_LFS_DATA_DIR |
options.data_directory |
ANCHOR_LFS_LOG_FORMAT |
options.log_format |
ANCHOR_LFS_LOG_LEVEL |
options.log_level |
ANCHOR_LFS_ACCESS_LOG |
options.access_log |
ANCHOR_LFS_BASE_URL |
options.base_url |
ANCHOR_LFS_TRUSTED_PROXIES |
options.trusted_proxies (comma-separated; set it empty to trust no one) |
ANCHOR_LFS_MAX_UPLOAD_SIZE |
options.max_upload_size |
ANCHOR_LFS_UPLOAD_IDLE_TIMEOUT |
options.upload_idle_timeout |
ANCHOR_LFS_RATE_LIMIT_TOKENS |
options.rate_limit_tokens |
ANCHOR_LFS_RATE_LIMIT_WINDOW |
options.rate_limit_window |
ANCHOR_LFS_AUTH_CACHE_TTL |
options.auth_cache_ttl |
ANCHOR_LFS_URL_EXPIRY |
options.url_expiry |
ANCHOR_LFS_SIGNING_KEY |
options.signing_key |
ANCHOR_LFS_SHUTDOWN_TIMEOUT |
options.shutdown_timeout |
ANCHOR_LFS_STORAGE_BACKEND |
storage.backend |
ANCHOR_LFS_S3_BUCKET |
storage.s3_bucket |
ANCHOR_LFS_S3_REGION |
storage.s3_region |
ANCHOR_LFS_S3_ENDPOINT |
storage.s3_endpoint |
ANCHOR_LFS_S3_ACCESS_KEY_ID |
storage.s3_access_key_id |
ANCHOR_LFS_S3_SECRET_ACCESS_KEY |
storage.s3_secret_access_key |
ANCHOR_LFS_S3_PREFIX |
storage.s3_prefix |
ANCHOR_LFS_S3_PRESIGNED_URLS |
storage.s3_presigned_urls |
ANCHOR_LFS_S3_FORCE_PATH_STYLE |
storage.s3_force_path_style |
ANCHOR_LFS_SIGNING_KEY_FILE, ANCHOR_LFS_S3_ACCESS_KEY_ID_FILE and ANCHOR_LFS_S3_SECRET_ACCESS_KEY_FILE name a file that holds the value of the variable without the _FILE suffix, such as a Compose secret mounted under /run/secrets. Whitespace around the value is ignored. Setting both forms of one variable, or naming a file that is missing, unreadable or empty, stops startup with an error.
- Environment variables (highest priority)
- TOML config file values
- Built-in defaults (lowest priority)
Note: Endpoint configuration ([[endpoints]]) cannot be overridden via environment variables. Endpoints must be defined in the config file.
An override with a value the server cannot use, such as ANCHOR_LFS_MAX_UPLOAD_SIZE=1G or ANCHOR_LFS_S3_PRESIGNED_URLS=yes, stops startup with an error naming the variable and its value. It is never ignored.
The server validates the entire configuration at startup. If anything is wrong, it exits and lists every problem it found in the log entry's errors field, so one restart shows them all. TOML syntax errors and unrecognised keys are reported first, on their own, because they cause misleading follow-on errors. Validation checks include:
- Every key and section must be one the server recognises, so a misspelled name stops startup instead of being ignored
- Environment variable overrides must be usable:
ANCHOR_LFS_MAX_UPLOAD_SIZEa positive number of bytes;ANCHOR_LFS_RATE_LIMIT_TOKENSa positive whole number;ANCHOR_LFS_ACCESS_LOG,ANCHOR_LFS_S3_PRESIGNED_URLSandANCHOR_LFS_S3_FORCE_PATH_STYLEtrueorfalse -
log_formatmust be"json"or"console", andlog_levelone of"debug","info","warn"or"error" -
max_upload_sizemust be positive -
metrics_addressmust be a host and numeric port, such as127.0.0.1:9420, on a different port fromlisten_address -
trusted_proxiesentries must be IP addresses or CIDR ranges - At least one endpoint must be configured
- Endpoint paths must start with
/and be clean: no trailing slash, empty segments, or dot segments - Endpoint paths must be unique and not use the reserved paths
/health,/ready,/locksand/signing.key(the last two compared ignoring case) - Endpoint paths must map to unique storage directories:
/org/repoand/org_repoboth map toorg_repo, and/Org/Repocollides with/org/repobecause names are compared ignoring case - Endpoint path segments may contain only letters, digits,
.,_and-, and the path may not start with/.or end with. - Authentication must be
"github"or"none" - Visibility must be
"public"or"private" - Private endpoints require authentication
"github" -
github_api_urlcan only be set when authentication is"github" - GitHub-authenticated endpoints must have a valid repository URL with
org/repoformat - Non-
github.comrepository URLs requiregithub_api_urlto be set - S3 backend requires
s3_bucketands3_region -
base_url,s3_endpoint, andgithub_api_urlmust be valid URLs when set -
github_api_urlmust usehttps;httpis accepted only forlocalhostand loopback addresses -
signing_keymust be valid hex and at least 32 bytes - Duration values (
rate_limit_window,auth_cache_ttl,url_expiry,shutdown_timeout,upload_idle_timeout) must be valid Go durations and positive, except thatauth_cache_ttlandupload_idle_timeoutmay be0s
- Storage Backends: Detailed storage configuration
- Authentication: Authentication setup
- Running the Server: Start the server