Multi-site support
CabloyJS supports the development of multi-site
through the mechanism of multi-instance
See also: EggBornJS: Multi-instance
Instance Configuration
In Cabloy-CMS, the domain name example.com
is generally left to the static parts
, so a sub domain name needs to be assigned to the dynamic parts
, such as admin.example.com
Name | Domain | Description |
---|---|---|
Static Parts | example.com | static files |
Dynamic Parts | admin.example.com | backend API services |
src/backend/config/config.prod.js
// instances
config.instances = [
{ subdomain: 'admin', password: '', title: '',
config: {
'a-base': {
jsonp: { whiteList: 'example.com' },
},
},
},
];
Name | Description |
---|---|
subdomain | subdomain |
password | the initial password of the user root |
title | website’s title |
- config:modules’s configuration in the instance
The configuration of module a-base
is modified here:
Name | Description |
---|---|
jsonp.whiteList | whitelist for cors. only domain names in the whitelist can access the backend API services through ajax |
Because the domain of
static parts
is different from the domain ofdynamic parts
,json.whitelist
must to be set
Build Frontend
$ npm run build:front
Start Backend Service
$ npm run start:backend
or
$ npm run start:backend -- --daemon --workers=2
- Do not forget to create a MySQL database and configure
src/backend/config/config.prod.js
Stop Backend Service
$ npm run stop:backend
Startup Parameters of Backend Service
build/config.js
:
// backend
const backend = {
port: 7002,
hostname: '127.0.0.1',
};
Nginx Configuration
It is highly recommended to use nginx
to host frontend static resources and to apply reverse proxy to backend service
Two nginx configuration files have been generated in the project root directory, which correspond to the dynamic and static parts of Cabloy-CMS respectively. Please modify them according to actual needs
Dynamic Parts: nginx.conf
See also: Nginx Configuration
Static Parts: nginx-cms.conf
server {
listen 80;
server_name example.com;
root {publicDir}/{instanceId}/cms/dist;
}
Comments: