1. To change from multiple-domain mode to single-domain mode, I modified the file: frontend/config/main.php. See Figure 1.

2. To change from multiple-domain mode to single-domain mode, I modified the file: etc/nginx/conf.d/ccp_api.conf. See Figure 2.

3. I now plan to allow switching the domain mode during container upgrades based on the environment variable: CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE=single|multiple. Default: single.
4. I decided to prepare two sets of files for the multiple-domain mode and use a shell script to check the environment variable CHANNEL_PUB_API_CFG_DOMAIN_NAME_MODE=multiple and execute the file copy accordingly.
5. I edited the shell script /config/init/config.sh, placing it before the other shell scripts. See Figure 3.

#!/bin/bash
env | grep CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE || export CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE="single"
if [[ $CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE == "multiple" ]]
then
\cp /mcloud/ccp_api.conf /etc/nginx/conf.d/
chmod +x /etc/nginx/conf.d/*
echo "前端的域名模式:多域名,复制 ccp_api.conf 至 /etc/nginx/conf.d/"
\cp /mcloud/frontend/config/main.php /mcloud/www/ccp_api/frontend/config/
echo "前端的域名模式:多域名,复制 main.php 至 /mcloud/www/ccp_api/frontend/config/"
elif [[ $CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE == "single" ]]
then
echo "前端的域名模式:单域名"
else
echo "please set environment variable CHANNEL_PUB_API_CFG_FRONTEND_DOMAIN_MODE single or multiple"
fi
6. Nginx failed to start. The reason was that config0.sh executed before config.sh. I renamed config.sh to ccp_init.sh.
[root@07ca67a1f3c1 conf.d]# nginx -t
nginx: [emerg] host not found in "CHANNEL_PUB_API_CFG_NGINX_AUTH_LISTEN" of the "listen" directive in /etc/nginx/conf.d/ccp_api.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
[root@07ca67a1f3c1 conf.d]#
7. Nginx has started. See Figure 4.

[root@b9b472c89102 /]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@b9b472c89102 /]#
