Requirements
- Public IP address or port forwarding or reverse proxy (Nginx, Caddy, etc.)
- HTTPS recommended for production (use Let’s Encrypt or similar)
- Access to firewall configuration (if applicable)
Basic setup
Configuration
Environment variables
| Variable | Default | settings.json | Description |
|---|---|---|---|
HAPI_LISTEN_HOST | 127.0.0.1 | listenHost | HTTP bind address |
HAPI_LISTEN_PORT | 3006 | listenPort | HTTP port |
HAPI_PUBLIC_URL | - | publicUrl | Public URL for external access |
CORS_ORIGINS | - | corsOrigins | Allowed CORS origins (comma-separated) |
CLI_API_TOKEN | Auto-generated | cliApiToken | Authentication token |
Configuration priority: ENV > settings.json > default
settings.json example
Create or edit~/.hapi/settings.json:
HTTPS setup
Option 1: Reverse proxy (recommended)
Use Nginx or Caddy to handle HTTPS certificates:- Caddy
- Nginx
Option 2: Self-signed certificates (development)
If using self-signed certificates, the CLI needs to trust them:CORS configuration
If accessing the hub from a different origin (e.g., standalone web app):settings.json:
If
HAPI_PUBLIC_URL is set, it’s automatically added to CORS origins.Firewall configuration
UFW (Ubuntu/Debian)
firewalld (RHEL/CentOS)
CLI configuration
If the hub is not on localhost, configure the CLI:Production deployment
Security considerations
Use HTTPS
Always use HTTPS in production. Use Let’s Encrypt for free certificates.
Restrict CORS
Only allow trusted origins in
CORS_ORIGINS to prevent unauthorized access.Firewall rules
Use firewall rules to restrict access to the hub port.
Rotate tokens
Keep
CLI_API_TOKEN secret and rotate if compromised.When to use self-hosted
Self-hosted deployment is ideal when:- You have a public IP or VPS
- You want complete control over infrastructure
- You need custom SSL certificates
- You’re deploying for a team or organization
- You want to avoid third-party relay servers
Troubleshooting
Cannot connect from remote machine
- Verify
HAPI_LISTEN_HOSTis0.0.0.0or your public IP - Check firewall allows port 3006
- Test with
curl http://your-ip:3006/api/health
CORS errors in browser
- Set
CORS_ORIGINSto include your web app origin - Or set
HAPI_PUBLIC_URLwhich automatically adds to CORS - Ensure the origin includes protocol (
https://, not just domain)
SSL certificate errors
- Use publicly trusted certificates (Let’s Encrypt recommended)
- For self-signed, set
NODE_EXTRA_CA_CERTSon CLI machine - Verify reverse proxy is correctly forwarding requests
Next steps
Telegram Setup
Configure Telegram notifications (requires HTTPS)
Runner Setup
Enable remote session spawning