Rewrites and SSL
Enable clean URLs and local HTTPS on your embedded server.
On this page
Most frameworks want clean URLs, and many features need HTTPS even in development. In this lesson you will turn on both in your server.json.
URL rewrites
With rewrites on, a URL like /index.cfm/main can simply be /main.
box server set web.rewrites.enable=true
Or for a single start:
box server start --rewritesEnable
If your web root has an index.bxm, requests are rewritten to that file. Otherwise they go to index.cfm. Use the rewritesFile argument to name a different front controller.
Local HTTPS
Turn on SSL and pick a port.
{
"web": {
"http": {
"port": 8080
},
"ssl": {
"enable": true,
"port": 8443
},
"rewrites": {
"enable": true
}
}
}
box server restart
Browse to https://127.0.0.1:8443. Without a certificate of your own the browser will warn that the connection is not trusted, which is fine for local work.
To use a real certificate, point at your files.
box server set web.ssl.certFile=/path/to/dev.crt
box server set web.ssl.keyFile=/path/to/dev.key
Multi-site SSL management is a CommandBox Pro feature, along with multi-site management and deployment, the OS service manager and server config sync with ForgeBox. Pro is included with BoxLang Essentials, BoxLang+ and BoxLang++ plans. See boxlang.io/plans.
Recap
web.rewrites.enablegives you clean URLs for your front controller.web.ssl.enableandweb.ssl.portadd an HTTPS listener.- Set
web.ssl.certFileandweb.ssl.keyFileto use your own certificate.