Configure Virtual Hosts in an Environment
Overview
This page describes how to configure delivery tier virtual hosts in a Bloomreach Experience Manager environment after the initial deployment.
Background
The delivery tier in Bloomreach Experience Manager supports multiple sites on different hostnames and enables cross-domain linking. Virtual host configuration is stored in the content repository and managed through the Console application.
Info: For details on the configuration model, see Request Matching, Hostname Matching, and Mount Matching.
Configure Virtual Hosts
This example assumes a production deployment with one site at https://www.example.com and the CMS application at https://cms.example.com.
-
Start with the default virtual hosts configuration for a new Bloomreach Experience Manager project:
/hst:myproject/hst:hosts: /dev-localhost: jcr:primaryType: hst:virtualhostgroup /localhost: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mountThis configuration defines the
localhostvirtual host for local development. -
Add a new virtual host group named
production-envby creating a node of typehst:virtualhostgroup:/hst:myproject/hst:hosts: /dev-localhost: jcr:primaryType: hst:virtualhostgroup /localhost: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount /production-env: jcr:primaryType: hst:virtualhostgroup -
In the
production-envgroup, create a reverse hierarchy for thewww.example.comdomain using nodes of typehst:virtualhost:/hst:myproject/hst:hosts: /dev-localhost: jcr:primaryType: hst:virtualhostgroup /localhost: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount /production-env: jcr:primaryType: hst:virtualhostgroup /com: jcr:primaryType: hst:virtualhost /example: jcr:primaryType: hst:virtualhost /www: jcr:primaryType: hst:virtualhost -
Copy the node at
hst:myproject/hst:hosts/dev-localhost/localhost/hst:roottohst:myproject/hst:hosts/production-env/com/example/www/hst:rootto mount the site at thewww.example.comvirtual host:/hst:myproject/hst:hosts: /dev-localhost: jcr:primaryType: hst:virtualhostgroup /localhost: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount /production-env: jcr:primaryType: hst:virtualhostgroup /com: jcr:primaryType: hst:virtualhost /example: jcr:primaryType: hst:virtualhost /www: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount -
Add the Boolean properties
hst:showportandhst:showcontextpath, both set tofalse, on thehst:rootnode:/hst:myproject/hst:hosts: /dev-localhost: jcr:primaryType: hst:virtualhostgroup /localhost: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount /production-env: jcr:primaryType: hst:virtualhostgroup /com: jcr:primaryType: hst:virtualhost hst:scheme: https hst:showport: false hst:showcontextpath: false /example: jcr:primaryType: hst:virtualhost /www: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mountInfo: Set
hst:scheme = httpsfor HTTPS-only environments (recommended). Usehst:scheme = httpfor HTTP-only, orhst:schemeagnostic = trueto support both protocols.Info: Setting
hst:showportandhst:showcontextpathtofalseensures that generated links do not include the context path or port. You can set these properties at any level in the virtual hosts configuration. Child nodes inherit these settings. -
Mirror the new virtual hosts group in the platform configuration to define the CMS mount:
/hst:platform/hst-hosts/production-env: jcr:primaryType: hst:virtualhostgroup /com: jcr:primaryType: hst:virtualhost hst:scheme: https hst:showport: false hst:showcontextpath: false /example: jcr:primaryType: hst:virtualhost /cms: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount hst:ismapped: false hst:namedpipeline: WebApplicationInvokingPipeline -
Save your changes to the repository.
Hint: Repeat steps 3 and 4 for each additional site you want to configure.
Use System Property Expansion in Virtual Host Configuration
Info: System property expansion is supported starting with Bloomreach Experience Manager 14.2.1.
In many deployment scenarios, such as blue-green deployments, the same distribution is deployed to multiple environments that differ only in hostname. To avoid duplicating virtual host configuration, you can use placeholders in the names of hst:virtualhost nodes. Placeholders use the syntax ${system.property.name} and are dynamically expanded at runtime based on system properties.
Example: Blue-Green Deployment in Bloomreach Cloud
In Bloomreach Cloud, an environment named myenvironment in the namespace mycompany is accessible at myenvironment.mycompany.bloomreach.cloud. In a blue-green deployment, environments might be named blue and green, with hostnames blue.mycompany.bloomreach.cloud and green.mycompany.bloomreach.cloud.
Bloomreach Cloud defines the system properties brc.environmentname and brc.namespace by default. You can use these properties to create generic virtual host configurations.
Site virtual host configuration:
/hst:myproject/hst:hosts: jcr:primaryType: hst:virtualhosts /br-cloud: jcr:primaryType: hst:virtualhostgroup /cloud: jcr:primaryType: hst:virtualhost /bloomreach: jcr:primaryType: hst:virtualhost /${brc.namespace}: jcr:primaryType: hst:virtualhost /${brc.environmentname}: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount hst:homepage: root hst:mountpoint: /hst:myproject/hst:sites/myproject
Platform virtual host configuration:
/hst:platform/hst:hosts: jcr:primaryType: hst:virtualhosts /br-cloud: jcr:primaryType: hst:virtualhostgroup /cloud: jcr:primaryType: hst:virtualhost /bloomreach: jcr:primaryType: hst:virtualhost /${brc.namespace}: jcr:primaryType: hst:virtualhost /${brc.environmentname}: jcr:primaryType: hst:virtualhost /hst:root: jcr:primaryType: hst:mount hst:ismapped: false hst:namedpipeline: WebApplicationInvokingPipeline