Configure

The hosts object

It contains the configuration for each of your website. 'default' may be the domain name or the IP address from which you reach the website.

exports.hosts = {

	'default' : {

		//...
	},

	'127.0.0.1' : {

		//...
	}
};

The auth sub-object

'auth' : {

	'active' : false,

	'credentials' : {

		'scope' : [
			{
				'username'	:	'user',
				'password'	:	'pwd'
			}
		]
	},

	'rules' : [
		{
			'path'	:	'',
			'realm'	:	'scope'
		}
	]
}

HTTP Basic authentication policy. Set the root policy first, then 1st level files/folders, then 2nd level files/folders, etc.

'active' : Enable HTTP Basic authentication management.
'credentials' : Sets of usernames/passwords
'path' : Relative path from the website root, without the leading slash.
'realm' : Set of usernames/passwords to use for this path.

The cache sub-object

'cache' : [
	{
		'action'	:	0,
		'expire'	:	0,
		'path'		:	''
	},
	{
		'action'	:	1,
		'expire'	:	0,
		'path'		:	'static'
	},
	{
		'action'	:	2,
		'expire'	:	86400,
		'path'		:	'static/permanent'
	}
]

Cache policy for static files. Set the root policy first, then 1st level files/folders, then 2nd level files/folders, etc.

'action' : 0 : No cache, 1 : With revalidation, 2 : Without revalidation until expiration.
'expire' : Used only when 'action' is set to 2. Seconds before expiration after cached.
'path' : Relative path from the website root, without the leading slash.

The error sub-object

'error' : {

	'active'	:	true,	// Enable error pages.
	'folder'	:	''		// Folder for custom dynamic error pages.
							// Relative path from the website root, without the leading and ending slashes.
}							// Empty for default pages.

The exec sub-object

'exec' : {

	'active'		:	true,						// Enable dynamic pages execution.
	'cache'			:	true,						// Put dynamic pages in memory cache.
	'ext'			:	'nodejs',					// Extension for dynamic pages.
	'mimetype'		:	'application/octet-stream'	// Default MIME type for dynamic pages.

}

The header sub-object

'header' : [
	{
		'list' : [
			{
				'name'	:	'Access-Control-Allow-Origin',
				'value'	:	'*'
			}
		],

		'path' : ''
	}
]

Custom headers for static files. Set the root policy first, then 1st level files/folders, then 2nd level files/folders, etc.

'list' : Headers list to add to the subfiles/subfolders.
'path' : Relative path from the website root, without the leading slash.

The index sub-object

'index' : {

	'active'	:	true,						// Enable index pages.
	'list'		:	true,						// Enable folder listing.
	'mimetype'	:	'application/octet-stream',	// Default MIME type for static content.
	'name'		:	[							// List of index pages names.

		'index.nodejs',
		'index.html',
		'index.htm',
		'index.xhtml',
		'index.xml'

	]
}

The memory sub-object

'memory' : true	// Cache static files.

The restrict sub-object

'restrict' : ['includes', 'protected']	// Restricted files/folders. Relative path from the website root, without the leading slash.

The restrict_ext sub-object

'restrict_ext' : ['temp', 'log']	// Restricted extensions.

The rewrite sub-object

'rewrite' : {

	'active'			:	false,	// Enable URL rewriting.
	'restrict_override'	:	false,	// Rewrite the URL after the restrictions check.
	'rules'				:	[		// Regex replacement rules.

		['^/js/(.*)$', 'gi', '/scripts/$1'],
		['^/css/(.*)$', 'gi', '/styles/$1']

	]
}

The root sub-object

'root' : '/var/www'	// Root of the website without the ending slash.

The session sub-object

'session' : {

	'active'	:	true,	// Enable session management.
	'clear'		:	300,	// Interval for cleaning sessions.
	'cookie'	:	'SID',	// Session cookie name. Must be URL encoded.
	'expire'	:	3600	// Session duration in s.
	
}

The memory object

exports.memory = {

	'active'		:	false,	// Use memory usage limits.
	'connection'	:	1024,	// Maximum size in MB of process RAM usage before refusing new connections.
	'interval'		:	1000,	// Updates interval in ms.
	'request'		:	512		// Maximum size in MB of process RAM usage before refusing new requests.

};

The server object

exports.server = {

	'app'			:	'',				// Absolute path of the installation folder without the ending slash.
	'log_error'		:	false,			// Print the 500 errors in the console.
	'net_interface'	:	'0.0.0.0',		// Interface on which the server listens. It can be an IP address or a hostname.
	'port'			:	80,				// Port on which to listen.
	'protocol'		:	'http://',		// Used protocol.
	'secure'		:	{},				// HTTPS options object.
	'send_version'	:	true,			// Sends an http header with the version of Cendre.
										// Shows the version of Cendre in error pages and folder listings.
	'version'		:	'Cendre/4.2.0'	// Version of Cendre.

};

The upload object

exports.upload = {

	'disk'		:	false,	// Use temporary files for requests' body.
	'disk_size'	:	16384,	// Maximum size in KB of temporary files.
	'ext'		:	'tmp',	// Temporary files extension.
	'folder'	:	'',		// Absolute path of the folder where temporary files are stored without the ending slash.
	'ram_size'	:	512,	// Maximum size in KB of requests' body stored in RAM.
	'read_size'	:	64		// Minimum size in KB before streaming/not caching static files.

};