Configure CAE for multi-tenancy
Multi-tenancy means that you host a single installation of a service or application for multiple tenants (customers).
A widely spread pattern for multi-tenancy is using tenant names in the hostname of the URL, e.g. for customer1 it would result to customer1.cae.davidsystems-test.com
CAE supports this pattern with the following features.
Tenant-dependent settings.json files
Setting multiTenantSettings to true in your main settings.json file will force CAE to read a settings file based on the hostname instead of the main settings.json file.
The file must be located under the folder assets (like the main setttings.json) and named according to the pattern: <hostname>___settings.json (hostname + 3 underscores + settings.json)
"caeSettings": {
...
"multiTenantSettings": true
...
}
Example:
hostname = customer1.cae.davidsystems-test.com
settings file = customer1.cae.davidsystems-test.com___settings.json
If the file cannot be found, CAE will not start but show an error message.
Using ${hostname} in Variables
An alternative or additional way to adapt to multi-tenancy is that the hostname (and some calculated variations of it) can be used as symbolic variable in the settings.json variables section.
${hostname} returns the complete hostname
${hostname:n} returns the part with index n (when you split the hostnames by dots and start counting by 0), e.g. ${hostname:0} returns the first part.
${hostname:n-} returns the hostname starting by index n up to the end of the hostname
Note: hostname resolution is only applied in the variables section, so you might need to add a helper variable there like in the example of Content Manager URL on the bottom of this page.
Example: derive the dpe service URL from the tenant name and the rest of the hostname
hostname pattern = customer1.cae.davidsystems-test.com
"variables": {
"basePath": "https://${hostname:0}.dpe.${hostname:2-}/DpeWebApplication"
}
hostname pattern = cae.customer1.davidsystems-test.com
"variables": {
"basePath": "https://dpe.${hostname:1-}/DpeWebApplication"
}
Example: derive the ContentManager URL from the tenant name and the rest of the hostname
hostname pattern = customer1.cae.davidsystems-test.com
"variables": {
"cm": "https://${hostname:0}.cm.${hostname:2-}",
"basePath": "https://${hostname:0}.dpe.${hostname:2-}/DpeWebApplication"
}
...
"importViaPostMessageApi": {
"origins": [ ${cm} ]
},
...
hostname pattern = cae.customer1.davidsystems-test.com
"variables": {
"cm": "https://cm.${hostname:1-}",
"basePath": "https://dpe.${hostname:1-}/DpeWebApplication"
}
...
"importViaPostMessageApi": {
"origins": [ ${cm} ]
},
...