This document discusses CommandBox and CFConfig, which are tools for managing ColdFusion servers from the command line. CommandBox allows starting, stopping, and configuring CF servers. CFConfig allows importing, exporting, and transferring ColdFusion server configurations between servers of different versions. It supports settings from Adobe and Lucee servers.
8. Commandbox CLI
• Command line tool
• Runs CFML from the console
○ REPL
○ CFM execution
○ Custom Commands
• Manages code libraries
•Use as a build tool
•Publish packages to ForgeBox
•Start/stop/manage servers
Brad Wood
Ortus Solutions
@bdw429s
9. What is CommandBox?
• Native binary
○ Windows
○ Mac
○ Linux
• No installation
•Small (~37MB)
•Downloads CF engines on demand
•Local artifacts
•Free open source
•Professionally supported
•www.patreon.com/ortussolutions
Brad Wood
Ortus Solutions
@bdw429s
10. Start servers
● Params
○ port
○ SSLEnable
○ rewritesEnable
○ cfengine
○ heapSize
● Separate process for each server
● Start more than one
Brad Wood
Ortus Solutions
@bdw429s
> start
> start port=8080 --rewritesEnabled
> start heapSize=1024 --!openBrowser
12. Configure Server
• Ports/host
○ HTTP
○ HTTPS
• Certs
• Bind to host
•JVM Settings
•Built in support for heap size
•Any other JVM args supported
○ Java agents
○ Debugger
○ System Properties
Brad Wood
Ortus Solutions
@bdw429s
13. server.json
● Persists all settings for starting a server
● Portable
● Created automatically
● Commands to manage
○ server set
○ server show
○ server clear
Brad Wood
Ortus Solutions
@bdw429s
{
"name":"myServer",
"app":{
"cfengine":"adobe@2016"
},
"web":{
"http":{
"port":8000
},
"rewrites":{
"enable":true
}
},
"jvm":{
"heapsize":1024
}
}
14. Managing multiple servers
• Named servers
• Different server.json files
• Listing & managing servers
• Server info
• Server cd
Brad Wood
Ortus Solutions
@bdw429s
15. Web aliases
• Map web URL to any file system path
• For static files or CFML
• Set in server.json
• Set in config setting server defaults
Brad Wood
Ortus Solutions
@bdw429s
{
"web":{
"aliases":{
"/bar":"foo"
}
}
}
16. Custom error pages
● Customize responses for
missing files
● Redirects to a file in the web
root
● Can be static or .cfm
● Any status code
○ 404
○ 500
○ default
Brad Wood
Ortus Solutions
@bdw429s
{
"web":{
"errorpages":{
"404":"/missing.htm",
"500":"/sorry.htm"
}
}
}
17. FusionReactor
• CommandBox Module
• Downloads on demand (and caches)
• Uses onServerStart interceptor to load JVM args
• Set license to use for all servers
• commands
○ fr register
○ fr open
Brad Wood
Ortus Solutions
@bdw429s
20. CFConfig CommandBox CLI
CFConfig Architecture
Brad Wood
Ortus Solutions
@bdw429s
CFConfig Service Layer
Base Adobe support
Base Lucee
support
2016 112018 45
Base Config Items
Property
Files
Password
encryption
JSON
Formatting
Semver
support
CLI Helper
Utilities
CFConfig Service
Server
Interceptors
CLI
Commands
10
21. CFConfig Architecture
● Over 200 separate config items supported
○ Datasources
○ Custom tags
○ Mail servers
○ Caches
○ Timeouts
○ Security settings
○ Anything in the Web Admin UI
Brad Wood
Ortus Solutions
@bdw429s
22. CFConfig Features
● Can read/write from/to
○ A JSON file
○ A CommandBox server
○ ANY server installation accessible via the file system
● The JSON file is engine/version agnostic!
○ Move settings from Lucee 4 to Adobe 11
○ Diff settings between Adobe 2016 and Adobe 11
Brad Wood
Ortus Solutions
@bdw429s
23. CFConfig Commands
● cfconfig set
● cfconfig show
● cfconfig export
● cfconfig import
● cfconfig transfer
● cfconfig diff
Brad Wood
Ortus Solutions
@bdw429s
24. CFConfig Commands
● cfconfig cache list / save / delete
● cfconfig cfmapping list / save / delete
● cfconfig datasource list / save / delete
● cfconfig mailserver list / save / delete
Brad Wood
Ortus Solutions
@bdw429s
25. CFConfig Commands
● Every setting can be viewed/set individually from the CLI
○ cfconfig show requestTimeout
○ cfconfig set requestTimeout=0,0,5,0
● Separate commands for “complex” settings
○ cfconfig datasource list
○ cfconfig datasource save …
○ cfconfig datasource delete …
Brad Wood
Ortus Solutions
@bdw429s
26. CFConfig Password Support
Brad Wood
Ortus Solutions
@bdw429s
● CF Admin passwords will transfer between like servers,
but not across engines (hashed)
● Mail server, datasource, and keystore passwords will
transfer anywhere! (decrypted and re-encrypted)
● Decryptable passwords are stored in JSON as plain text!!
○ More on how to avoid this later
27. CFConfig Interceptors
Brad Wood
Ortus Solutions
@bdw429s
● CommandBox server interceptors
○ Auto-import settings via JSON
■ .cfconfig.json file in webroot
■ Or specify a path in server.json
■ Or specify a path in `cfconfigfile` environment var
○ Auto-transfer previous settings on server upgrade
■ The original idea that sparked CFConfig!!
○ Auto-save settings on server stop
■ Disabled by default. Enable with config setting
28. CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
● System Settings
○ For portability
○ Can be different for user/environment
○ For Security
● Combination of JVM properties and OS Env vars
○ JVM props get precedence
● Placeholders can be used in CLI shell, box.json,
server.json and .cfconfig.json!
● Actually a core feature of CommandBox 3.7.0+
29. CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
● Placeholders look like this:
○ ${my.jvm.prop.name}
○ ${MY_OS_ENV_VAR}
● Supply Default like so:
○ ${HTTP_PORT:8080}
○ ${HTTP_HOST:127.0.0.1}
● Default default value is empty string
30. CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
● You need to quote them in JSON.
● The JSON is parsed first, then the system settings are
expanded
{
“name” : “myServer”,
“debug” : “${DEBUG_START:false}”,
“web” : {
“http” : {
“port” : “${HTTP_PORT:8080}”
}
}
}
31. CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
● Use them in your CFConfig JSON to externalize passwords
or settings
● More than one system setting can be expanded in a value
{
“adminPassword” : “${ADMIN_PASS}”,
“mySetting” : “text${foo}here${bar}too”
}
32. Environment Overrides
Brad Wood
Ortus Solutions
@bdw429s
● Environment variables whose names start with
“cfconfig_” are picked up automatically and stored
● Loaded AFTER .cfconfig.json
● Great for ad-hoc setting overrides
cfconfig_adminPassword=$uper$ecure
cfconfig_license=123abcEnterprise
cfconfig_flashRemotingEnable=false
33. CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
● Set in your local Operating System
● Set on your cloud deploy
○ Docker
○ Travis-CI
○ etc
● Use commandbox-dotenv!
○ “.env” file in the web root (git ignore it)
○ Loads properties into server automatically!
34. Case Study
Brad Wood
Ortus Solutions
@bdw429s
● Govt client needed to configure CF11 STIG on new servers
● Dozens of specific settings needed to be set in the CF admin
● Usually a manual process
● We created a JSON file to represent all the Govt CF11 STIG
lockdown settings
● Client is now able to script the import of all settings in a single
command with CFConfig
$> box cfconfig import STIG.json
35. Ortus Docker Images
Brad Wood
Ortus Solutions
@bdw429s
● Based on CommandBox
● Fully configurable via CFConfig
● Professionally supported via Ortus
● In use with multiple clients including the US Navy
● Built in URL Rewrites
● CF Admin automatically locked down
● Health check URIs for Docker Swarm
● Available on Docker Hub
$> docker pull ortussolutions/commandbox