Environment Variables
Configuration reference for self-hosting LinkForty Core. Set these in your .env file (or your platform's environment configuration). Only DATABASE_URL is strictly required; everything else has a sensible default or is optional.
Database
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL | Yes | — | PostgreSQL connection string: postgresql://user:password@host:5432/dbname. |
POSTGRES_DB | No | — | Database name (Docker Compose convenience; used to compose DATABASE_URL). |
POSTGRES_USER | No | — | Database user (Docker Compose). |
POSTGRES_PASSWORD | No | — | Database password (Docker Compose). |
POSTGRES_PORT | No | 5432 | Database port (Docker Compose). |
Caching (optional)
| Variable | Required | Default | Description |
|---|---|---|---|
REDIS_URL | No | — | Redis connection string for link caching (redis://host:6379). Omit to disable — Core falls back to direct database queries. |
REDIS_PORT | No | 6379 | Redis port (Docker Compose). |
Server
| Variable | Required | Default | Description |
|---|---|---|---|
NODE_ENV | No | development | Set to production in production (enables SSL behavior and hides internal error details). |
PORT | No | 3000 | Port the server listens on. |
HOST | No | 0.0.0.0 | Bind address. |
LINKFORTY_CONFIG | No | linkforty.config.json in the working directory | Path to Core's configuration file. |
CORS_ORIGIN | No | * | Allowed CORS origin(s). Set to your frontend domain in production. |
SHORTLINK_DOMAIN | No | the request's host | Base URL encoded in QR codes, including the scheme (https://go.yourdomain.com). |
Attribution behind a proxy or CDN
| Variable | Required | Default | Description |
|---|---|---|---|
TRUST_PROXY | No | unset | Number of reverse proxies between the visitor and Core (1 for a single nginx). Core then reads the visitor's IP from X-Forwarded-For. true trusts every hop. Read by the Docker image and the example server; with the npm package, pass trustProxy to createServer(). |
TRUSTED_CLIENT_IP_HEADER | No | unset | Name of a header carrying the authoritative client IP, e.g. cf-connecting-ip. When set, Core reads that header and ignores X-Forwarded-For. |
When neither is set, Core uses the IP of the connection. Behind any reverse proxy or CDN (nginx, Caddy, a load balancer, a Kubernetes ingress, Cloudflare), that is the proxy's address, not the visitor's: 127.0.0.1 for an nginx on the same host, an edge address for a CDN.
This breaks deferred deep linking outright. Core matches an install to the click that led to it by comparing device signals, and the IP is the signal it requires: without an IP match no click can reach the confidence threshold. Core also refuses to match on loopback and private addresses, since they cannot identify a device. So behind an unconfigured proxy every install is organic. Geo-targeting and the location columns in analytics fail the same way.
Pick the setting that matches what is in front of Core:
# A reverse proxy that sets X-Forwarded-For: nginx, Caddy, HAProxy, a load
# balancer, an ingress controller. One proxy → 1; a load balancer in front of
# nginx → 2.
TRUST_PROXY=1
# A CDN with its own client-IP header. Core reads that header instead.
TRUSTED_CLIENT_IP_HEADER=cf-connecting-ip # Cloudflare
TRUSTED_CLIENT_IP_HEADER=true-client-ip # Akamai and some other CDNs
TRUST_PROXY is the right choice for the nginx setup in the self-hosting guide. Comma-separated header values are handled (Core takes the first entry), and IPv6-mapped IPv4 addresses are normalized.
Both settings trust what the proxy says about the visitor. Set them only when Core is reachable exclusively through that proxy: bind Core to 127.0.0.1 or firewall its port. A client that can reach Core directly could otherwise forge its IP. When no proxy is in front of Core, leave both unset.
To verify, click a test link from a phone and check the click in link analytics: it should carry the visitor's country and city, not the server's.
On LinkForty Cloud this is already configured. You only need these variables for a self-hosted deployment behind a proxy or CDN.
Bot detection (optional)
| Variable | Required | Default | Description |
|---|---|---|---|
ASN_DB_PATH | No | — | Path to an IP-to-ASN database in MMDB format. Setting it turns on experimental scanner detection. Read by the Docker image and the example server; with the npm package, pass botDetection.asnDatabasePath. |
TRUST_EDGE_BOT_HEADER | No | unset | Set to true to accept the x-lf-bot header (1 or true) as a signal that a click came from a bot. Only enable it behind a proxy that sets this header and strips copies sent by clients; otherwise a client could mark its own clicks. |
Mobile app links
These power the .well-known files Core serves for iOS Universal Links and Android App Links. See iOS Universal Links and Android App Links for setup.
| Variable | Required | Default | Description |
|---|---|---|---|
IOS_TEAM_ID | No | — | Apple Developer Team ID. Required to serve apple-app-site-association. |
IOS_BUNDLE_ID | No | — | Your iOS app bundle identifier (e.g. com.yourcompany.yourapp). |
ANDROID_PACKAGE_NAME | No | — | Your Android package name. Required to serve assetlinks.json. |
ANDROID_SHA256_FINGERPRINTS | No | — | Comma-separated SHA-256 signing-certificate fingerprints. |
When the iOS pair is unset, GET /.well-known/apple-app-site-association returns a 404 with a configuration message. The same applies to the Android pair and assetlinks.json.
Example .env
# Database
DATABASE_URL=postgresql://linkforty:your-strong-password@localhost:5432/linkforty
# Caching (optional)
REDIS_URL=redis://localhost:6379
# Server
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
CORS_ORIGIN=https://yourdomain.com
SHORTLINK_DOMAIN=https://go.yourdomain.com
# Behind a reverse proxy (nginx, a load balancer): the number of proxies in
# front of Core, so the visitor's IP is read from X-Forwarded-For
TRUST_PROXY=1
# Behind Cloudflare instead: read its client-IP header
# TRUSTED_CLIENT_IP_HEADER=cf-connecting-ip
# iOS Universal Links
IOS_TEAM_ID=ABC123XYZ
IOS_BUNDLE_ID=com.yourcompany.yourapp
# Android App Links
ANDROID_PACKAGE_NAME=com.yourcompany.yourapp
ANDROID_SHA256_FINGERPRINTS=AA:BB:CC:DD:...
Related
- Self-Hosting Guide — full deployment walkthrough
- SDK Integration — Universal Links / App Links setup
- Attribution Windows — tune match windows