Multi Domain Dispatcher Configuration

Currently, most companies have multiple domains; they want to serve these domain requests from one single AEM instance, because of the obvious cost and management savings.
This article describes configuring multiple domains (/content/geometrixx-outdoors and /content/geometrixx-media) and their caching mechanisms in AEM.

The below configuration changes are validated in:

  • Linux
  • AEM 6.2 (no service packs or hot fixes)
  • Apache 2.4 (Make sure you use the port number: 80. You can use any port you want, but you have to change the below config files)
  • Dispatcher versions: 4.2.2

Set up the AEM Instances:
Install and configure the AEM author and publish instances. Please see the below link on how to install the AEM on your local environment: Local Install

Dispatcher Setup:
The process to setup a Dispatcher for your local environment is considerably easier than you think. If you need help, see the below documents:

Caching Location:
Let’s set up a separate caching locations for both the domains.
Create the below folders under /var/www/html:
Make sure to give the full permissions to these folders so dispatcher can write the files to these folders.
sudo chmod -R 0644 /var/www/html/geometrixx-outdoors
sudo chmod -R 0644 /var/www/html/geometrixx-media

The idea is to place the geometrixx-outdoors website cache under: /var/www/html/ geometrixx-outdoors folder and geometrixx-media cache under: /var/www/html/ geometrixx-media.

Virtual Hosts:
When you have multiple domains, you need to create a separate dispatcher urls for each domain.
In this article, I am using the below url: to hit the geometrixx outdoors pages. to hit the geometrixx media pages.
Default dispatcher setup will have only one virtual host. Let’s say you have two domains, then you need to create two separate virtual host files.
1. Create geometrixx-outdoors.conf file under: /etc/apache2/sites-enabled
2. Open the above file and paste the below content:

geometrixx-outdoors-redirects.conf can have the url shortening configs, rewrites and redirects configurations.

You can include them in this virtual host also. You don’t need a separate file. However, it comes in handy in the maintenance if you fork this out.
3. Create geometrixx-media.conf file under: /etc/apache2/sites-enabled
4. Open the above file and paste the below content:

geometrixx-media-redirects.conf can have the url shortening configs, rewrites and redirects configurations.
Make sure you are loading/including these two conf files in apache2.conf.
IncludeOptional /etc/apache2/ sites-enabled /geometrixx-outdoors.conf
IncludeOptional /etc/apache2/ sites-enabled /geometrixx-media.conf

Farm files setup:
It is important to set up the separate farm files for easy maintenance. You can have one single file for multiple domains. However, you can achieve the following goals if you have a separate farm file for each domain:
1. Restricting a specific path(s) in one domain while allowing access in the other domain
2. Enable caching for specific types of files in one domain, while denying caching in the other domain
3. Maintaining separate. stat file depth (/statfileslevel)
4. Enable ttl on one domain and disable on the other domain.
5. Maintain separate headers for each domain
6. Maintain separate vanity url file for each domain
I’ve listed only a few use cases to demonstrate the use of a separate farm file.
Create a separate farm file for geometrixx-outdoors and make sure you configure the correct virtual host. See below.

Create a separate farm file for geometrixx-outdoors and make sure you configure the correct virtual host. See below.

Make sure to include these two farm files in your dispatcher.conf file.

Disabling the cross-domain access:
Users can access geometrixx-media pages from and vice versa. To avoid this, you should throw an error page when user are trying to access another domain page. You can use RewriteCond to achieve this.

Add the below conditions to geometrixx-outdoors-redirects.conf file.

Add the below conditions to geometrixx-media-redirects.conf file.

Setting the dispatcher flush agents:
You should set up a separate flush agent for each domain. Below is the dispatcher flush agent configuration for geometrixx-outdoors.
1. Transport tab settings:

2. Make sure this agent has the below headers.

3. Trigger this agent whenever it receives the replication events:

Similarly, create a new dispatcher flush agent for geometrixx-media and follow steps 1-3. Make sure you change the URI.

Flushing Cache:
When authors replicate the geometrixx-outdoors page then it should touch the corresponding .stat files to invalidate the cache. Similarly, when authors replicate the geometrixx-media pages, it should invalidate the geometrixx-media pages.

To achieve this, make sure you have the below configuration in your apache2.conf file:

In the above config, its reading the header values set in the dispatcher flush agents and determining the host.

Modify the host file:
You need to modify your local host file to test these changes. You need to add the below entries to your host file:

Restart the apache and test your changes.


ivo_eersels2Author bio
Singaiah Chintalapudi is a Senior Developer who has worked on a multitude of AEM implementations. He has been working with AEM since 2012 and is heavily involved in designing and developing numerous AEM projects. His interests include performance optimization, security, scalability, and third-party integrations with AEM.