This document contains the actual implementation details of how Convox v3 works, discovered by analyzing the source code.
The following Convox repositories are available for reference in ./reference/:
reference/convox/- The Convox CLI source code (github.com/convox/convox)reference/convox_rack/- The Convox Rack API server (github.com/convox/rack)reference/convox_racks_terraform/- Our Terraform configurations for self-hosted racks
The Rack Gateway acts as an authentication and authorization proxy between developers and self-hosted Convox racks:
Developer → rack-gateway CLI → Gateway API Server → Convox Rack
- Install CLI: Binary installed at
/usr/local/bin/rack-gateway - Login to Rack:
rack-gateway login staging https://rack-gateway.example.com - Configuration: Stored in
~/.config/rack-gateway/config.json{ "gateways": { "staging": { "url": "https://rack-gateway.example.com" } }, "tokens": { "staging": { "token": "session-token-here", "email": "user@example.com", "expires_at": "2024-02-01T00:00:00Z" } } }
The gateway server (run by admins) needs:
-
Environment Variables:
RACK_URL_STAGING=https://api.staging.convox.cloudRACK_TOKEN_STAGING=actual-convox-rack-tokenGOOGLE_CLIENT_ID=oauth-client-idGOOGLE_CLIENT_SECRET=oauth-client-secretAPP_SECRET_KEY=session-secret-key
-
No config/racks.yaml: Racks are discovered from environment variables
The rack-gateway CLI wraps the real convox CLI:
- Developer runs:
rack-gateway apps - CLI loads gateway URL and session token from
~/.config/rack-gateway/config.json - CLI sets
RACK_URL=https://convox:<session-token>@gateway.example.com - CLI executes:
convox appswith the RACK_URL environment variable - Real convox CLI connects to gateway using session token as password
- Gateway validates session token, checks RBAC permissions
- Gateway proxies request to real Convox rack using actual token
The gateway is fully compatible with the native Convox CLI - no wrapper needed:
# For CI/CD with API token
export RACK_URL="https://convox:<api-token>@gateway.example.com"
convox apps # Uses native convox CLI directly
# For developers with session token
export RACK_URL="https://convox:<session-token>@gateway.example.com"
convox apps # Uses native convox CLI directlyThe rack-gateway CLI wrapper simply provides convenience features:
- Manages multiple rack configurations
- Handles session token storage
- Provides login/logout commands
- Automatic token refresh reminders
But it's completely optional - the gateway speaks the same API as a real Convox rack.
-
Terraform State: Stored in S3, contains sensitive outputs including the API URL with embedded credentials
{ "api": { "sensitive": true, "type": "string", "value": "https://convox:<auth-token>@api.af6a420efa1ea995.convox.cloud" } } -
Authentication Format: HTTP Basic Auth embedded in URL
- Username:
convox(fixed) - Password: The rack's API token
- Example:
https://convox:token123@api.rack.convox.cloud
- Username:
-
Local Configuration:
- Config location:
~/Library/Preferences/convox/(macOS) - Linux would use:
~/.config/convox/(XDG standard) - Windows:
%LOCALAPPDATA%\convox\
- Config location:
-
Current Rack Selection:
~/Library/Preferences/convox/current{ "name": "staging", "type": "terraform" } -
Rack Types:
terraform: Local terraform management (runs terraform commands locally)console: Convox Cloud managed (terraform runs on Convox servers)test: Test/mock rack- Direct: When
RACK_URLenv var is set
The CLI checks in this order (from pkg/rack/rack.go):
-
RACK_URLenvironment variable - Direct connection, bypasses all configexport RACK_URL="https://convox:token@api.rack.convox.cloud"
-
--rackflag - Command line argumentconvox --rack staging apps
-
GATEWAY_RACKenvironment variable - Rack nameexport GATEWAY_RACK=staging -
Local
.convox/rackfile - Project-specific rack selection -
Global
currentsetting - From~/Library/Preferences/convox/current
| Aspect | Terraform Rack | Console Rack |
|---|---|---|
| State Management | Local machine runs terraform |
Convox Cloud runs terraform |
| Credentials | In terraform state (S3) | In Convox Cloud |
| Auth Storage | No separate auth (in URL) | Auth tokens in settings |
| Use Case | Self-hosted, full control | Managed service |
- Protocol: HTTPS with Basic Auth
- Base Path: Varies by operation (e.g.,
/apps,/ps,/releases) - Auth Header: Constructed from URL as
Authorization: Basic base64(convox:token) - Response Format: JSON
- Terraform state contains the real API URL with embedded token
- Anyone with S3 access can get the token
- No individual user authentication or audit trail
- Shared credentials across all users
-
Deploy auth proxy on same rack as
convox-api-proxy.DOMAIN -
Use
RACK_URLoverride to point Convox CLI to proxy:export RACK_URL="https://convox:SESSION_TOKEN@convox-api-proxy.domain"
-
Proxy accepts session token as Basic Auth password:
- Username:
convox(ignored) - Password: User's session token from OAuth login
- Username:
-
Proxy forwards to real Convox API:
- Validates session token and checks RBAC
- Strips incoming Basic Auth
- Adds real rack's Basic Auth
- Forwards request to actual Convox API
- No terraform state access needed for developers
- Standard Convox CLI works unchanged via
RACK_URL - Individual authentication per developer
- Complete audit trail with user attribution
- RBAC enforcement before reaching real API
- Token rotation possible without affecting users
Instead of reimplementing all Convox commands, rack-gateway acts as a wrapper:
-
Handles authentication:
rack-gateway login staging # Performs OAuth, stores session token -
Wraps standard Convox CLI:
rack-gateway apps # Sets RACK_URL with session token # Executes: convox apps
-
Environment Setup:
RACK_URL = "https://convox:{SESSION_TOKEN}@proxy.domain" exec("convox", args...)
- Single shared token for entire rack
- Token visible to anyone with terraform state access
- No audit trail of who did what
- No ability to revoke individual access
- No granular permissions
- Individual session tokens per user
- Real rack token never exposed to users
- Complete audit log with user email
- 30-day token expiry with rotation
- RBAC with roles (viewer, ops, deployer, admin)
- Ability to revoke individual access
- Accept Basic Auth: Extract session token from password field
- Validate session token: Check signature and expiry
- Check RBAC: Verify user has permission for request
- Transform Auth: Replace with real rack's Basic Auth
- Audit Log: Record user, action, result
- Forward Request: Proxy to actual Convox API
For security, the proxy should block rack management operations:
convox rack updateconvox rack uninstallconvox rack params set- Any terraform state modifications
These should only be done by infrastructure team with direct terraform access.
- Set up proxy on Convox rack
- Create test user in RBAC system
- Login via OAuth:
rack-gateway login staging
- Test standard commands:
export RACK_URL="https://convox:$SESSION_TOKEN@proxy.domain" convox apps convox ps -a myapp convox logs -a myapp
- Verify audit logs show user attribution
- Test RBAC blocks unauthorized operations
Convox applications define multiple service types in their convox.yml:
web: The main web application service that handles HTTP requestsworker: Background job processors (e.g., Sidekiq, Resque)command: A special service type that doesn't run containers by default, used exclusively for one-off commands like migrations, rake tasks, and console access
During continuous deployment, the pipeline executes specific commands in sequence:
convox rack- Verify rack connectivity and statusconvox ps- Check current running processesconvox build- Build new Docker images from sourceconvox run- Execute pre-release tasks:- Database migrations:
convox run command "bin/pre_release" - DNS verification and smoke test:
convox run command "run_as_deploy rake checks:verify_dns checks:generate_test_submission" - Stripe configuration:
convox run command "rake stripe:prepare"
- Database migrations:
convox releases promote- Promote the new release to production
The convox run command allows executing commands in containers, but should be restricted based on service type:
- Blocked:
convox run webandconvox run worker- These should never be allowed as they could interfere with running services - Allowed (with restrictions):
convox run command- Only for specific approved commands - Special Access:
convox run command "rails console"- Should be restricted to admin-level users only- Note: Rails console itself has additional protection with email/password login and 2FA required at the CLI level
The CI/CD pipeline uses a limited set of commands with specific parameters:
# Pre-release tasks
convox run command "bin/pre_release"
convox run command "run_as_deploy rake checks:verify_dns checks:generate_test_submission"
convox run command "rake stripe:prepare"
# Deployment
convox releases promoteCertain commands require elevated privileges:
# Console access (admin only)
convox run command "rails console"
# Database operations
convox run command "rake db:migrate"
convox run command "rake db:seed"$ convox help
convox api get query the rack api
convox apps list apps
convox apps cancel cancel an app update
convox apps create create an app
convox apps delete delete an app
convox apps export export an app
convox apps import import an app
convox apps info get information about an app
convox apps lock enable termination protection
convox apps params display app parameters
convox apps params set set app parameters
convox apps unlock disable termination protection
convox balancers list balancers for an app
convox build create a build
convox builds list builds
convox builds export export a build
convox builds import import a build
convox builds info get information about a build
convox builds logs get logs for a build
convox certs list certificates
convox certs delete delete a certificate
convox certs generate generate a certificate
convox certs import import a certificate
convox certs renew renew a certificate
convox config get get the config
convox config set set the config
convox configs list of app configs
convox cp copy files
convox deploy create and promote a build
convox env list env vars
convox env edit edit env interactively
convox env get get an env var
convox env set set env var(s)
convox env unset unset env var(s)
convox exec execute a command in a running process
convox help list commands
convox instances list instances
convox instances keyroll roll ssh key on instances
convox instances ssh run a shell on an instance
convox instances terminate terminate an instance
convox letsencrypt dns route53 add configure letsencrypt dns route53 solver
convox letsencrypt dns route53 delete delete letsencrypt dns route53 solver
convox letsencrypt dns route53 list list letsencrypt dns route53 solver
convox letsencrypt dns route53 role letsencrypt dns route53 role arn
convox letsencrypt dns route53 update update letsencrypt dns route53 solver
convox login authenticate with a rack
convox logs get logs for an app
convox proxy proxy a connection inside the rack
convox ps list app processes
convox ps info get information about a process
convox ps stop stop a process
convox rack get information about the rack
convox rack access get rack access credential
convox rack access key rotate rotate access key
convox rack install install a new rack
convox rack kubeconfig generate kubeconfig for rack
convox rack logs get logs for the rack
convox rack mv move a rack to or from console
convox rack params display rack parameters
convox rack params set set rack parameters
convox rack ps list rack processes
convox rack releases list rack version history
convox rack runtime attach attach runtime integration
convox rack runtimes list attachable runtime integrations
convox rack scale scale the rack
convox rack sync sync v2 rack API url
convox rack uninstall uninstall a rack
convox rack update update a rack
convox racks list available racks
convox registries list private registries
convox registries add add a private registry
convox registries remove remove private registry
convox releases list releases for an app
convox releases info get information about a release
convox releases manifest get manifest for a release
convox releases promote promote a release
convox releases rollback copy an old release forward and promote it
convox resources list resources
convox resources console start a console for a resource
convox resources export export data from a resource
convox resources import import data to a resource
convox resources info get information about a resource
convox resources proxy proxy a local port to a resource
convox resources url get url for a resource
convox restart restart an app
convox run execute a command in a new process
convox runtimes get list of runtimes
convox scale scale a service
convox services list services for an app
convox services restart restart a service
convox ssl list certificate associates for an app
convox ssl update update certificate for an app
convox start start an application for local development
convox switch switch current rack
convox test run tests
convox update update the cli
convox version display version information
convox workflows get list of workflows
convox workflows run run workflow for specified branch or commit