Deploy

2018-12-22 07:51:47

Instances and domain names

Cabloy supports the development of multi-domain sites through the concept of multi-instance, with instances corresponding to the subdomains of the website. Such as instance1.cabloy.com and instance2.cabloy.com.

In the local development environment, Cabloy has enabled a default instance; but in a production deployment environment, you need to plan the mapping between instances and subdomains.

In the Cabloy-CMS application, domain name example.com has left for static files, so you need to assign a subdomain to the backend management system, such as admin.example.com.

Multi-site support

Since one instance corresponds to one CMS application, multiple sites can be supported by multiple instances.

Instance configuration

Edit file: src/backend/config/config.prod.js

// instances
config.instances = [
  { subdomain: 'admin', password: '', title: '',
    config: {
      'a-base': {
        jsonp: { whiteList: 'example.com' },
      },
    },
  },
];
Name Instruction
subdomain subdomain
password The initial access password of the user root in the instance
title Website title
config[‘a-base’].jsonp.whiteList Cross-domain access whitelist, only domain names in the whitelist can access the backend API interface through ajax

Build frontend code

$ npm run build:front

Start backend service

$ npm run start:backend

  • Do not forget to create a MySQL database and configure src/backend/config/config.prod.js

Stop backend service

$ npm run stop:backend

Backend service startup parameter configuration

Edit file: 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 services.

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 part: nginx.conf

server {

  listen 80;
  server_name admin.example.com;
  set $node_port 7002;

  root /Users/wind/Documents/temp/cabloy-cms/dist;

  location /public {
    root /Users/wind/cabloy/cabloy-cms;
    internal;
  }

  location  /api/ {
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_pass http://127.0.0.1:$node_port$request_uri;
    proxy_redirect off;
  }

}

Static part: nginx-cms.conf

server {

  listen 80;
  server_name example.com;

  root /Users/wind/cabloy/cabloy-cms/public/1/cms/dist;

}


Comments: