Skip to main content

Sitecore

Configuring Multiple Sites to Run on Sitecore in Docker Containers

jumping on containers

I recently went about setting up Sitecore’s Lighthouse Demo . While I found the documentation on setting things up fine, with several blog posts that describe it in more detail, once things were running and I could see the Lifestyle Lighthouse Site on the CD url. But when logging into the CM server, I noticed there were actually several other sites in the Content tree.

Lighthouse Demo Content Tree

Later I realized, each site was mapped to a virtual directory on the CD url (e.g. /financial), but by then I already started to try to figure out how to map each of these sites to their own urls. To do that, there are several steps that you’ll need to take: some that you’re probably used to and a couple of extra steps since everything runs in docker. These steps will work for the Lighthouse demo sites as well as any other multi site solution you have running on docker that uses Trafeik as a reverse proxy.

Step 1: Host Entries

First thing we need to do is add a few urls to our host file, located under c:\windows\system32\drivers\etc\

Lighthouse Hosts File

Since my plan was to leave the lifestyle site mapped to the cd url, I only added urls for the financial, healthcare and cumulus sites.

Step 2: SXA configuration

Since these are all SXA sites, the next thing we need to do is configure Site Groupings  for the three new sites. Under each sites, setting node, there is a “Site Grouping” folder, with an entry for that site underneath. On that item, you need to populate a host name and remove the virtual folder setting.

Lighthouse Site Grouping Settings

 

To make sure this configuration looked good, and that the additional sites weren’t impacted by the wildcard configuration of the lifestyle site,  I checked the SXA site manager. Everything looked good, but if you see any issues here, you may just need to reorder the sites to make sure the wildcard match happens after the other sites are resolved.

Lighthouse Sxa Site Manager

While you’re here, it’s probably a good idea to hit the publish button and make sure the site definitions are published.

Step 3: Configure Traefik

If you stop there and try to address the urls you entered, you’ll get a plain 404 error.

Here is where things get more complicated. Since everything is running in docker, we need to tell the docker Traefik instance to route our new host urls to the CD instance. To do this, we’ll need to modify the rule in the docker-compose file that configures our CD instances. If we look in the “docker-compose-xp1.override.yml file, you’ll notice the rule that controls the mapping is located in the labels for the cd definition. There you will see:

 - "traefik.http.routers.cd-secure.rule=Host(`${CD_HOST}`)"

Looking for the best way to add our additional host, I consulted the host rule documentation for Traefik :

Traefik Host Rule Doc

The documentation on the host method, shows that we can just provide a comma separated list of hosts. And while I could have parameterized the other url’s, I went quick and dirty and just included them directly inline (note I used the angled quotes to be consistent).

Lighthouse Cd Host Rule

Step 4: Docker Down and Up

To get this to be applied, you just need to run “docker-compose down” and then “docker-compose up -d”.

After it finishes, the additional sites should all be addressable using their own urls.

Sitecore Lighthouse Financial Home Page

Sitecore Lighthouse Healthcare Home Page

Sitecore Lighthouse Cumulus Home Page

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

David San Filippo, Principal

David is the Prinicpal of the Sitecore and Optimizely practice at Perficient, David estimates, architects and delivers digital marketing solutions at scale on the Sitecore Platform. A 4X Sitecore Technology MVP, David has written articles for MSDN Magazine and the Microsoft Architecture Journal. He has spoken at Sitecore Symposium, Sitecore Virtual Developer Day, user group meetings and code camps.

More from this Author

Categories
Follow Us