Skip to main content

Environment Variables

Complete reference of all environment variables for configuring Bloqd.

Required Variables

These variables must be set for Bloqd to function properly.

VariableDescriptionExample
API_KEY_SALTSalt for hashing API keys. Must be unique and secret.a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
API_BASE_URLExternal URL that agents use to connecthttps://bloqd.example.com
Critical Security Setting

The API_KEY_SALT is used to hash all API keys. If you change it after deployment:

  • All existing API keys will stop working
  • All connected agents will lose access
  • You'll need to regenerate all keys

Generate a secure salt:

openssl rand -hex 16

Server Configuration

VariableDescriptionDefault
NODE_ENVEnvironment mode (development or production)production
PORTHTTP port to listen on3000
HOSTIP address to bind to0.0.0.0
DATABASE_PATHPath to SQLite database file./data/bloqd.db
BASE_URLBase URL for email links (password reset, etc.)http://localhost:5173
LOG_LEVELLogging verbosity: debug, info, warn, errorinfo

Example

NODE_ENV=production
PORT=3000
HOST=0.0.0.0
DATABASE_PATH=/app/data/bloqd.db
BASE_URL=https://bloqd.example.com
LOG_LEVEL=info

Authentication

VariableDescriptionDefault
JWT_SECRETSecret for signing JWT access tokensAuto-generated
JWT_REFRESH_SECRETSecret for signing JWT refresh tokensAuto-generated
ADMIN_SETUP_KEYInitial admin setup key (optional)-
Auto-Generated Secrets

JWT_SECRET and JWT_REFRESH_SECRET are automatically generated on first startup and saved to your .env file. You don't need to set these manually.

AbuseIPDB Integration

Report malicious IPs to AbuseIPDB automatically.

VariableDescriptionDefault
ABUSEIPDB_ENABLEDEnable AbuseIPDB integrationfalse
ABUSEIPDB_API_KEYYour AbuseIPDB API key-
ABUSEIPDB_RATE_LIMITMaximum reports per rolling window1000

Example

ABUSEIPDB_ENABLED=true
ABUSEIPDB_API_KEY=abc123def456ghi789jkl012mno345pqr678
ABUSEIPDB_RATE_LIMIT=1000

Getting an API Key

  1. Create an account at abuseipdb.com
  2. Go to AccountAPI
  3. Create a new API key
  4. Copy the key to your .env file

Discord Integration

Receive real-time notifications in Discord.

VariableDescriptionDefault
DISCORD_ENABLEDEnable Discord notificationsfalse
DISCORD_WEBHOOK_URLDiscord webhook URL-
DISCORD_NOTIFY_BANSSend notifications for new banstrue
DISCORD_NOTIFY_SYNCSSend notifications for sync eventstrue
DISCORD_NOTIFY_ERRORSSend notifications for errorstrue
DISCORD_DAILY_SUMMARYSend daily summary reportstrue
DISCORD_DAILY_SUMMARY_HOURHour (UTC) to send daily summary (0-23)8

Example

DISCORD_ENABLED=true
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/123456789/abcdefghijklmnop
DISCORD_NOTIFY_BANS=true
DISCORD_NOTIFY_SYNCS=true
DISCORD_NOTIFY_ERRORS=true
DISCORD_DAILY_SUMMARY=true
DISCORD_DAILY_SUMMARY_HOUR=8

Creating a Webhook

  1. Open Discord and go to your server
  2. Server SettingsIntegrationsWebhooks
  3. Click New Webhook
  4. Choose a channel and name
  5. Copy the webhook URL

Complete Example

Here's a complete .env file with all options:

.env
# ===========================================
# SERVER CONFIGURATION
# ===========================================
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
DATABASE_PATH=/app/data/bloqd.db
LOG_LEVEL=info

# ===========================================
# URLS
# ===========================================
# External URL for agent connections (REQUIRED)
API_BASE_URL=https://bloqd.example.com

# Base URL for email links
BASE_URL=https://bloqd.example.com

# ===========================================
# SECURITY (REQUIRED)
# ===========================================
# Generate with: openssl rand -hex 16
API_KEY_SALT=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6

# Optional: Initial admin key for setup
# ADMIN_SETUP_KEY=your-setup-key

# JWT secrets (auto-generated if not set)
# JWT_SECRET=
# JWT_REFRESH_SECRET=

# ===========================================
# ABUSEIPDB INTEGRATION
# ===========================================
ABUSEIPDB_ENABLED=true
ABUSEIPDB_API_KEY=your-abuseipdb-api-key-here
ABUSEIPDB_RATE_LIMIT=1000

# ===========================================
# DISCORD INTEGRATION
# ===========================================
DISCORD_ENABLED=true
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/xxx/xxx
DISCORD_NOTIFY_BANS=true
DISCORD_NOTIFY_SYNCS=true
DISCORD_NOTIFY_ERRORS=true
DISCORD_DAILY_SUMMARY=true
DISCORD_DAILY_SUMMARY_HOUR=8

Docker Compose with Environment Variables

When using Docker Compose, you can either use an .env file or set variables directly:

docker-compose.yaml
services:
bloqd:
image: clusterzx/bloqd:latest
env_file:
- .env
# ...

Direct Environment Variables

docker-compose.yaml
services:
bloqd:
image: clusterzx/bloqd:latest
environment:
- NODE_ENV=production
- PORT=3000
- API_KEY_SALT=${API_KEY_SALT}
- API_BASE_URL=https://bloqd.example.com
- DISCORD_ENABLED=true
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
# ...

Mixed Approach

Use .env for secrets and inline for non-sensitive values:

docker-compose.yaml
services:
bloqd:
image: clusterzx/bloqd:latest
env_file:
- .env # Contains API_KEY_SALT, DISCORD_WEBHOOK_URL, etc.
environment:
- NODE_ENV=production
- LOG_LEVEL=info
# ...

Environment Variable Precedence

When the same variable is defined in multiple places, this is the order of precedence (highest to lowest):

  1. Direct environment: in docker-compose.yaml
  2. .env file via env_file:
  3. Shell environment variables
  4. Default values in application

Troubleshooting

Variable Not Being Read

  1. Check the variable name is correct (case-sensitive)
  2. Ensure no trailing spaces in .env file
  3. Restart the container after changes: docker compose restart

Secrets in Logs

By default, sensitive variables are not logged. If you need to debug:

# Check environment inside container
docker exec bloqd env | grep -E "(API_KEY|DISCORD)"

Special Characters

If your value contains special characters, wrap it in quotes:

# Wrong
API_KEY_SALT=abc$123

# Correct
API_KEY_SALT="abc$123"