Skip to content

Examples Configurations

Michael Anderson edited this page Dec 1, 2017 · 1 revision

Configuration

Configuration is done in a JSON file. The default configuration file location is in conf/server.json. An optional path can be used by using the -c flag on the command line. An applet is defined by it's container (web path) and it's path (file system path). Currently, only HTTP, HTTP/2, and HTTPS protocols, with or without WebSockets, are supported.

Basic HTTP and HTTPS Configuration

{
    "autoLoadApplets": "./applets",
    "applets": [],
    "protocols": [
        {
            "name": "http",
            "port": 8080,
            "listen": "0.0.0.0",
            "websockets": true
        }, {
            "name": "https",
            "port": 8443,
            "listen": "0.0.0.0",
            "ssl": true,
            "cert": "./encryption/coffeecat.crt",
            "key": "./encryption/coffeecat.key"
        }
    ],
    "errorTemplate": "./conf/errors.ejs"
}

autoLoadApplets

Specifies a file system location from which to automatically add applets to the applets array. Applets are sub directories of this location and are loaded by directory name. That is if there is a directory called hello, the applet there will be mounted at /hello. The only exception to this is a directory called ROOT which will be mounted at the webserver root.

applets

An array of applet definitions.

container
The web root of the applet,
path
The file system path to the applet.

protocols

Currently supports http and https. Defines the ports to listen on, whether it is encrypted, and whether WebSockets are enabled.

name
The name of the protocol, e.g. "http" or "https"
port
The numeric port for the protocol to listen on.
listen
A string of the interface address to listen on, or a boolean. False turns off the protocol, True is the same as "0.0.0.0", but not the same as the IPv6 equivalent "::".
ssl
Indicates whether an SSL certificate should be associated with this protocol.
cert
The SSL certificate location relative to the root directory of the coffeecat installation.
key
The SSL private key location relative to the root directory of the coffeecat installation.
websockets
Indicates whether to attach a WebSockets server on top of this protocol

IPv6

To listen on IPv6 addresses along with IPv4 addresses, just duplicate the protocol settings and include an IPv6 address.

{
    "autoLoadApplets": "./applets",
    "applets": [],
    "protocols": [
        {
            "name": "http",
            "port": 8080,
            "listen": "0.0.0.0",
            "websockets": true
        }, {
            "name": "http",
            "port": 8080,
            "listen": "::",
            "websockets": true
        }
    ],
    "errorTemplate": "./conf/errors.ejs"
}

Clone this wiki locally