Deployment Guide
Deployment Guide
Section titled “Deployment Guide”This guide covers deploying Bifrost in production environments using Docker, systemd (Linux), and launchd (macOS).
Docker Deployment
Section titled “Docker Deployment”Quick Start with Docker Compose
Section titled “Quick Start with Docker Compose”The easiest way to deploy Bifrost is using Docker Compose:
cd dockerdocker-compose up -dThis starts:
| Service | Port | Description |
|---|---|---|
| bifrost-server | 8080 | HTTP proxy |
| bifrost-server | 1080 | SOCKS5 proxy |
| bifrost-server | 8081 | Web UI |
| bifrost-server | 8082 | REST API |
| bifrost-server | 9090 | Prometheus metrics |
| bifrost-client | 3128 | Local HTTP proxy |
| bifrost-client | 1081 | Local SOCKS5 proxy |
| prometheus | 9091 | Metrics collection |
| grafana | 3000 | Dashboards |
Docker Compose Configuration
Section titled “Docker Compose Configuration”version: '3.8'
services: bifrost-server: image: bifrost-server:latest container_name: bifrost-server restart: unless-stopped ports: - "8080:7080" # HTTP proxy - "1080:7180" # SOCKS5 proxy - "9090:7090" # Metrics - "8081:7081" # Web UI - "8082:7082" # API volumes: - bifrost-data:/app/data - bifrost-logs:/var/log/bifrost environment: - TZ=UTC healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost:7090/metrics"] interval: 30s timeout: 5s retries: 3
volumes: bifrost-data: bifrost-logs:Building Docker Images
Section titled “Building Docker Images”# Build server imagedocker build -t bifrost-server:latest -f docker/Dockerfile .
# Build client imagedocker build -t bifrost-client:latest -f docker/Dockerfile.client .Custom Configuration
Section titled “Custom Configuration”Mount your own config file:
volumes: - ./my-config.yaml:/app/data/config.yamlEnvironment Variables
Section titled “Environment Variables”Pass configuration via environment variables:
environment: - BIFROST_LOG_LEVEL=debug - BIFROST_API_TOKEN=your-secret-tokenDocker Commands
Section titled “Docker Commands”# Start servicesdocker-compose up -d
# View logsdocker-compose logs -f bifrost-server
# Stop servicesdocker-compose down
# Rebuild and restartdocker-compose up -d --build
# Check statusdocker-compose psLinux (systemd)
Section titled “Linux (systemd)”Prerequisites
Section titled “Prerequisites”- Create the bifrost user and group:
sudo useradd -r -s /sbin/nologin bifrost- Create directories:
sudo mkdir -p /etc/bifrostsudo mkdir -p /var/log/bifrostsudo chown bifrost:bifrost /var/log/bifrost- Install the binary:
sudo cp bin/bifrost-server /usr/local/bin/sudo chmod +x /usr/local/bin/bifrost-server- Copy your configuration:
sudo cp server-config.yaml /etc/bifrost/sudo chown bifrost:bifrost /etc/bifrost/server-config.yamlsudo chmod 600 /etc/bifrost/server-config.yamlServer Service File
Section titled “Server Service File”Create /etc/systemd/system/bifrost-server.service:
[Unit]Description=Bifrost Proxy ServerDocumentation=https://github.com/rennerdo30/bifrost-proxyAfter=network-online.targetWants=network-online.target
[Service]Type=simpleUser=bifrostGroup=bifrost
ExecStart=/usr/local/bin/bifrost-server -c /etc/bifrost/server-config.yamlExecReload=/bin/kill -HUP $MAINPID
Restart=alwaysRestartSec=5
# Security hardeningNoNewPrivileges=yesPrivateTmp=yesProtectSystem=strictProtectHome=yesReadWritePaths=/var/log/bifrost
# Resource limitsLimitNOFILE=65536LimitNPROC=4096
# LoggingStandardOutput=journalStandardError=journalSyslogIdentifier=bifrost-server
[Install]WantedBy=multi-user.targetClient Service File
Section titled “Client Service File”Create /etc/systemd/system/bifrost-client.service:
[Unit]Description=Bifrost Proxy ClientDocumentation=https://github.com/rennerdo30/bifrost-proxyAfter=network-online.targetWants=network-online.target
[Service]Type=simpleUser=bifrostGroup=bifrost
ExecStart=/usr/local/bin/bifrost-client -c /etc/bifrost/client-config.yamlExecReload=/bin/kill -HUP $MAINPID
Restart=alwaysRestartSec=5
NoNewPrivileges=yesPrivateTmp=yes
StandardOutput=journalStandardError=journalSyslogIdentifier=bifrost-client
[Install]WantedBy=multi-user.targetManaging the Service
Section titled “Managing the Service”# Reload systemdsudo systemctl daemon-reload
# Enable on bootsudo systemctl enable bifrost-server
# Start the servicesudo systemctl start bifrost-server
# Check statussudo systemctl status bifrost-server
# View logssudo journalctl -u bifrost-server -f
# Reload configuration (hot-reload)sudo systemctl reload bifrost-server
# Restart servicesudo systemctl restart bifrost-server
# Stop servicesudo systemctl stop bifrost-serverLog Rotation
Section titled “Log Rotation”Create /etc/logrotate.d/bifrost:
/var/log/bifrost/*.log { daily missingok rotate 14 compress delaycompress notifempty create 0640 bifrost bifrost sharedscripts postrotate systemctl reload bifrost-server >/dev/null 2>&1 || true endscript}macOS (launchd)
Section titled “macOS (launchd)”Prerequisites
Section titled “Prerequisites”- Install the binary:
sudo cp bin/bifrost-client /usr/local/bin/sudo chmod +x /usr/local/bin/bifrost-client- Create directories:
sudo mkdir -p /etc/bifrostsudo mkdir -p /var/log/bifrostsudo mkdir -p /var/lib/bifrost- Copy your configuration:
sudo cp client-config.yaml /etc/bifrost/Client Launch Agent (User)
Section titled “Client Launch Agent (User)”For running as the current user, create ~/Library/LaunchAgents/com.bifrost.client.plist:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key> <string>com.bifrost.client</string>
<key>ProgramArguments</key> <array> <string>/usr/local/bin/bifrost-client</string> <string>-c</string> <string>/etc/bifrost/client-config.yaml</string> </array>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>StandardOutPath</key> <string>/var/log/bifrost/client.log</string>
<key>StandardErrorPath</key> <string>/var/log/bifrost/client.error.log</string>
<key>WorkingDirectory</key> <string>/var/lib/bifrost</string></dict></plist>Managing the Launch Agent
Section titled “Managing the Launch Agent”# Load (start) the servicelaunchctl load ~/Library/LaunchAgents/com.bifrost.client.plist
# Unload (stop) the servicelaunchctl unload ~/Library/LaunchAgents/com.bifrost.client.plist
# Check if runninglaunchctl list | grep bifrost
# View logstail -f /var/log/bifrost/client.logSystem-Wide Daemon
Section titled “System-Wide Daemon”For running as a system daemon, place the plist in /Library/LaunchDaemons/ and use:
sudo launchctl load /Library/LaunchDaemons/com.bifrost.client.plistWindows
Section titled “Windows”Note: Authentication Limitation System authentication (
auth.mode: system) is not supported on Windows. Usenative,ldap, oroauthauthentication instead. See the Authentication Guide for details.
Manual Installation
Section titled “Manual Installation”-
Download the Windows binary (
bifrost-server.exeorbifrost-client.exe) -
Create a configuration directory:
Terminal window mkdir C:\ProgramData\Bifrost -
Copy your config file to
C:\ProgramData\Bifrost\config.yaml -
Run from command line:
Terminal window bifrost-server.exe -c C:\ProgramData\Bifrost\config.yaml
Windows Service (NSSM)
Section titled “Windows Service (NSSM)”Use NSSM to run Bifrost as a Windows service:
# Install as servicenssm install BifrostServer C:\path\to\bifrost-server.exe -c C:\ProgramData\Bifrost\config.yaml
# Start the servicenssm start BifrostServer
# Stop the servicenssm stop BifrostServer
# Remove the servicenssm remove BifrostServerFirewall Configuration
Section titled “Firewall Configuration”Allow Bifrost through Windows Firewall:
# HTTP ProxyNew-NetFirewallRule -DisplayName "Bifrost HTTP Proxy" -Direction Inbound -LocalPort 8080 -Protocol TCP -Action Allow
# SOCKS5 ProxyNew-NetFirewallRule -DisplayName "Bifrost SOCKS5 Proxy" -Direction Inbound -LocalPort 1080 -Protocol TCP -Action Allow
# Web UINew-NetFirewallRule -DisplayName "Bifrost Web UI" -Direction Inbound -LocalPort 8081 -Protocol TCP -Action AllowHealth Checks
Section titled “Health Checks”HTTP Health Check
Section titled “HTTP Health Check”curl http://localhost:7082/api/v1/healthExpected response:
{"status": "healthy", "time": "2024-01-15T10:30:00Z"}Prometheus Metrics
Section titled “Prometheus Metrics”curl http://localhost:7090/metricsDocker Health Check
Section titled “Docker Health Check”The Docker Compose configuration includes built-in health checks that verify the service is responding.
Upgrading
Section titled “Upgrading”Docker
Section titled “Docker”# Pull new imagesdocker-compose pull
# Restart with new imagesdocker-compose up -dSystemd
Section titled “Systemd”# Stop servicesudo systemctl stop bifrost-server
# Replace binarysudo cp new-bifrost-server /usr/local/bin/bifrost-server
# Start servicesudo systemctl start bifrost-serverConfiguration Changes
Section titled “Configuration Changes”Most configuration changes can be applied via hot-reload:
# Systemdsudo systemctl reload bifrost-server
# Dockerdocker exec bifrost-server kill -HUP 1Warning: Restart Required Some changes require a full restart:
- Listener address/port changes
- TLS certificate changes
- Authentication mode changes