Skip to main content

Bare Metal Deployment

This guide covers deploying Idenplane directly on bare metal or dedicated servers without containerization. It includes systemd service setup, database installation, reverse proxy configuration, and production hardening.


Prerequisites​

RequirementVersion
Node.js24 (the only version CI tests)
PostgreSQL16+
System memory512 MB minimum
Disk space2 GB minimum
User privilegessudo/root for service installation
note

In the published benchmark a single Idenplane process used about 194 MiB of RAM at idle, so it fits small VPS instances or dedicated servers.


Installing from Source​

1. Install Node.js​

Use Node.js 24, the version the Docker image and CI use:

# Using NodeSource repository (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify installation
node --version # Should be v24.x.x
npm --version

For other distributions, see the official Node.js installation guide.

2. Install PostgreSQL​

Idenplane needs PostgreSQL 16 or later. Older distributions ship an older postgresql package (Ubuntu 22.04 has 14); use the PostgreSQL apt repository there.

# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y postgresql postgresql-client

# Start PostgreSQL
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Create database and user
sudo -u postgres psql << 'EOF'
CREATE USER idenplane WITH PASSWORD 'your_secure_password';
CREATE DATABASE idenplane OWNER idenplane;
GRANT ALL PRIVILEGES ON DATABASE idenplane TO idenplane;
EOF

For other distributions, see the PostgreSQL installation guide.

3. Install Redis (Optional)​

Redis is optional but recommended for session caching and improved performance:

# Ubuntu/Debian
sudo apt-get install -y redis-server

# Start Redis
sudo systemctl start redis-server
sudo systemctl enable redis-server

Building Idenplane​

1. Clone and Install Dependencies​

git clone https://github.com/idenplane/idenplane.git
cd idenplane

# Install backend dependencies
npm install

# Install Admin UI dependencies
cd admin-ui && npm install && cd ..

2. Configure Environment​

# Copy the example environment file
cp .env.example .env

# Edit with your production settings
nano .env

Required environment variables for production:

# Database (required)
DATABASE_URL=postgresql://idenplane:your_secure_password@localhost:5432/idenplane

# Server
PORT=3000
NODE_ENV=production
BASE_URL=https://auth.yourdomain.com

# Security (required in production)
ADMIN_API_KEY=your-secure-api-key-here # Generate with: openssl rand -hex 32
WEBHOOK_SECRET_KEY=your-webhook-secret # Generate with: openssl rand -hex 32
WEBHOOK_ENCRYPTION_SALT=your-salt # Generate with: openssl rand -hex 16

# Redis (optional)
REDIS_URL=redis://localhost:6379
SESSION_STORE=redis

A first start in production also needs ADMIN_PASSWORD for the initial admin user; the server refuses to create it without one. In production ADMIN_API_KEY must be at least 32 characters, or the server exits at startup. node scripts/setup-env.cjs writes a .env with all of these generated.

warning

Always generate secure secrets for production. Never use default or placeholder values:

# Generate secure secrets
openssl rand -hex 32 # For ADMIN_API_KEY
openssl rand -hex 32 # For WEBHOOK_SECRET_KEY
openssl rand -hex 16 # For WEBHOOK_ENCRYPTION_SALT

3. Set Up Database​

# Generate Prisma client
npm run prisma:generate

# Apply migrations (production: deploy, never `migrate dev`)
npx prisma migrate deploy

Don't run npm run prisma:seed on a production database: it loads development sample data.

4. Build the Application​

# Build the admin console and the server, and copy the console into dist/admin-ui
npm run build:all

Systemd Service Setup​

1. Create the Service File​

Create /etc/systemd/system/idenplane.service:

[Unit]
Description=Idenplane Identity Server
Documentation=https://docs.idenplane.com
After=network.target postgresql.service redis.service
Wants=postgresql.service redis.service

[Service]
Type=simple
User=idenplane
Group=idenplane
WorkingDirectory=/opt/idenplane
Environment=NODE_ENV=production
EnvironmentFile=/opt/idenplane/.env
ExecStart=/usr/bin/node dist/cluster.js
Restart=on-failure
RestartSec=10s
StandardOutput=journal
StandardError=journal
SyslogIdentifier=idenplane

# Security: Run as non-root user
User=idenplane
Group=idenplane
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/idenplane /var/log/idenplane

[Install]
WantedBy=multi-user.target

2. Create the Idenplane User​

# Create system user (no login shell)
sudo useradd --system --home /opt/idenplane --shell /usr/sbin/nologin idenplane

# Create directories
sudo mkdir -p /opt/idenplane /var/log/idenplane
sudo chown -R idenplane:idenplane /opt/idenplane /var/log/idenplane

3. Copy Build Files​

# Copy the built application
sudo cp -r . /opt/idenplane/
sudo chown -R idenplane:idenplane /opt/idenplane

# Copy environment file
sudo cp .env /opt/idenplane/.env
sudo chmod 600 /opt/idenplane/.env
sudo chown idenplane:idenplane /opt/idenplane/.env

4. Enable and Start the Service​

# Reload systemd
sudo systemctl daemon-reload

# Enable service to start on boot
sudo systemctl enable idenplane

# Start the service
sudo systemctl start idenplane

# Check status
sudo systemctl status idenplane

5. Managing the Service​

# View logs
sudo journalctl -u idenplane -f

# Restart after config changes
sudo systemctl restart idenplane

# Stop the service
sudo systemctl stop idenplane

# View recent logs
sudo journalctl -u idenplane --since "1 hour ago"

Reverse Proxy Configuration​

Nginx​

Install Nginx:

sudo apt-get install -y nginx

Create /etc/nginx/sites-available/idenplane:

upstream idenplane_backend {
server 127.0.0.1:3000;
keepalive 32;
}

server {
listen 80;
server_name auth.yourdomain.com;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl http2;
server_name auth.yourdomain.com;

# SSL configuration
ssl_certificate /etc/letsencrypt/live/auth.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/auth.yourdomain.com/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;

# Modern TLS configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;

# HSTS
add_header Strict-Transport-Security "max-age=63072000" always;

# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;

# Proxy configuration
location / {
proxy_pass http://idenplane_backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_buffering off;
}

# Large file support for SAML metadata
location /realms {
proxy_pass http://idenplane_backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10M;
}
}

Enable the site:

sudo ln -s /etc/nginx/sites-available/idenplane /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

For SSL with Let's Encrypt:

sudo apt-get install -y certbot python3-certbot-nginx
sudo certbot --nginx -d auth.yourdomain.com

Caddy​

Create /etc/caddyfile:

auth.yourdomain.com {
reverse_proxy localhost:3000

# Modern TLS (managed automatically)
tls {
dns cloudflare {env.CLOUDFLARE_API_TOKEN}
}

# Security headers
header {
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
X-XSS-Protection "1; mode=block"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
}

# Logging
log {
output file /var/log/caddy/idenplane.log
}
}

Enable and start Caddy:

sudo systemctl enable --now caddy

Database Backups​

Automated Backups with Cron​

Create /etc/cron.d/idenplane-backup:

# Idenplane database backup - daily at 2 AM
0 2 * * * postgres pg_dump -U idenplane idenplane | gzip > /var/backups/idenplane/idenplane_$(date +\%Y\%m\%d).sql.gz

Backup Script​

Create /opt/idenplane/backup.sh:

#!/bin/bash
set -e

BACKUP_DIR="/var/backups/idenplane"
DATABASE_URL="postgresql://idenplane:your_password@localhost:5432/idenplane"
RETENTION_DAYS=30

# Create backup directory
mkdir -p "$BACKUP_DIR"

# Create timestamped backup
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
FILENAME="idenplane_${TIMESTAMP}.sql.gz"

pg_dump "$DATABASE_URL" | gzip > "$BACKUP_DIR/$FILENAME"

# Remove old backups
find "$BACKUP_DIR" -name "idenplane_*.sql.gz" -mtime +$RETENTION_DAYS -delete

# Log completion
echo "[$(date)] Backup completed: $FILENAME"
chmod +x /opt/idenplane/backup.sh

Firewall Configuration​

UFW (Ubuntu)​

# Allow SSH (before enabling firewall!)
sudo ufw allow 22/tcp

# Allow HTTP/HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

# Enable firewall
sudo ufw enable

# Check status
sudo ufw status

firewalld (CentOS/RHEL)​

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Monitoring​

Health Checks​

Idenplane provides health check endpoints:

EndpointDescription
http://localhost:3000/health/liveLiveness check
http://localhost:3000/health/readyReadiness check (includes database)
http://localhost:3000/admin/metricsPrometheus metrics (needs admin credentials)

systemd has no built-in HTTP health check; poll /health/ready from your monitoring.

Prometheus Metrics​

The metrics endpoint is /admin/metrics. It needs admin credentials: the x-admin-api-key header or an admin bearer token. With Prometheus 3, send the API key with http_headers, read from a file only Prometheus can read:

# /etc/prometheus/prometheus.yml
scrape_configs:
- job_name: 'idenplane'
metrics_path: '/admin/metrics'
http_headers:
x-admin-api-key:
files: ['/etc/prometheus/idenplane-admin-api-key']
static_configs:
- targets: ['localhost:3000']

Prometheus 2 cannot send custom headers; put a reverse proxy in front that adds the header for the scraper only, and never expose that proxy publicly.

Logs​

Idenplane writes JSON logs (Pino) to stdout and stderr, not to files. With the unit above they go to the journal:

sudo journalctl -u idenplane -f

Set the journal's retention in /etc/systemd/journald.conf (for example SystemMaxUse=); there are no log files for logrotate.


Updating Idenplane​

1. Stop the Service​

sudo systemctl stop idenplane

2. Pull Latest Code​

cd /opt/idenplane
sudo -u idenplane git pull origin main

3. Rebuild​

# Install dependencies
sudo -u idenplane npm install

# Build the admin console and the server
sudo -u idenplane bash -c "cd admin-ui && npm install"
sudo -u idenplane npm run build:all

4. Run Migrations​

sudo -u idenplane npx prisma migrate deploy

5. Start the Service​

sudo systemctl start idenplane
sudo systemctl status idenplane

Security Hardening​

File Permissions​

# Set correct ownership
sudo chown -R idenplane:idenplane /opt/idenplane

# Remove group/other permissions
sudo chmod -R o-rwx /opt/idenplane
sudo chmod 600 /opt/idenplane/.env

Brute force and Fail2Ban​

Idenplane has its own protection: per-account lockout (on for realms created since 0.10.0) and per-IP rate limits. See Secure defaults.

If you also want Fail2Ban, write the filter against the JSON log lines the server actually writes to the journal (backend = systemd, journalmatch = _SYSTEMD_UNIT=idenplane.service). Idenplane ships no ready-made filter.


Troubleshooting​

Service Won't Start​

  1. Check logs:

    sudo journalctl -u idenplane -n 100
  2. Verify environment variables:

    sudo -u idenplane cat /opt/idenplane/.env
  3. Test database connection:

    sudo -u idenplane psql $DATABASE_URL -c "SELECT 1"

Database Connection Issues​

  1. Verify PostgreSQL is running:

    sudo systemctl status postgresql
  2. Check connection:

    psql -U idenplane -h localhost -d idenplane -c "SELECT 1"
  3. Review connection string in .env

High Memory Usage​

  1. Check process memory:

    ps aux | grep idenplane
    top -p $(pgrep -f idenplane)
  2. Enable Redis for caching to reduce memory:

    # In .env
    REDIS_URL=redis://localhost:6379
    SESSION_STORE=redis
  3. Restart after changes:

    sudo systemctl restart idenplane

Next Steps​

Environment Variables Complete list of all configuration options

Configuration Detailed configuration guide

Docker Compose Deploy using Docker Compose

Kubernetes Deploy on Kubernetes


idenplane.com · GitHub · Discord