Imagine a case where you need having two Sitecore instances in parallel next to each other. That may be cause by several legit reasons.
For example, in my case I am moving (by reworking, not just migrating) some functional areas from one legacy instance to another that will features SXA. The legacy instance has been passed from one hand to another with numerous configuration artifacts, with a limited maintenance options, so that it becomes next to impossible to combine it with a brand new SXA stuff under the same roof. I know, that is doable in principle (and have done it myself before), but the amount maintenance and lack of knowledge / documentation on existing codebase makes its maintenance inappropriately risky and non-acceptable. Therefore, it becomes reasonable keeping them both in isolation, only uniting at the URL level (by rewriting a (sub)domain of a new instance into a primary domain's folder level).
Things you have to consider in that case would turn to almost doubling your infrastructure and related expense as well as checking if your Sitecore licence permits you that. Currently doing quite an unusual setup where both the above concerns give me a green light for going ahead and I am OK to run both instances in parallel (as on-prem solution).
Once agreed, the next thoughts come to Identity Server, where keeping two instances for that same activity does not make much sense. Keeping them both is exhaustive, but the good news is that one can re-use and existing ID Server for any number of instances (namely CM boxes). That comes to making two extra steps and below I will show you how-to:
Let's assume we have two instances, called old and new. Old one has all the bits configured and running, so we only want re-using ID Server of old instance with a new instance.
1. Get rid ow ID Server for a new instance (you can stop its web app and app pool for now). That makes sure it is not used.
Sitecore.Owin.Authentication.IdentityServer.config file on a new instance (
App_Config\Sitecore\Owin.Authentication.IdentityServer.config) and substitute identityServerAuthority variable to point to an existing ID Server
<sc.variable name = "identityServerAuthority" value = "https://old.identityserver" />
3. Now CM for a new instance knows which ID Server to talk through, but will ID Server accept those calls? The answer is no, unless you explicitly permit it doing so. Navigate to
Config\production folder of old instance ID Server and add addition allowed CORS origin group into
Sitecore.IdentityServer.Host.xml file. You will end up having smth. as below:
<AllowedCorsOrigins> <AllowedCorsOriginsGroup1> https://old </AllowedCorsOriginsGroup1> <AllowedCorsOriginsGroup2> https://new </AllowedCorsOriginsGroup2> </AllowedCorsOrigins>
4. There is also Identity Server secret stored below at the same xml file, with a matching counterpart at
App_Config\ConnectionStrings.config, so you also need updating config for new instance with the value from shared Identity Server:
<add name = "sitecoreidentity.secret" connectionString = "SECRET_from_ID_Server" />
5. Finally, recycle Identity Server application pool, then you're OK to test it. To make things more visual, I've recorded all the steps and testing it and sharing resulted video below:
Things to consider: as you're re-using existing old instance Identity
Server, it will itself re-use all the assets. When it comes to Active
Directory then it brings a desired result, but speaking about internal
users (those normally you have got at Sitecore domain) - they will all
get reused all as well, including admin. This comes because ID Server
has a reference to core database (or security database extracted from the core) and that one belongs by default to an old instance too.
Hope you find this helpful!