Call your Site with your own DNS

on local using SXA

Overview:

There are a lot of bricks and pieces on the web who to setup DNS for a local Site in SXA but no end to end description. At least I could not find it. Here's one from A-Z 

 

1. Decide for a DNS

2. Put DNS is Host File

3. Setup Self Signed Certificate (for local)

4. Setup Bindings

5. Do site configuration in Site Definition item

 

1. Decide for a DNS

I have plenty of Sitecore instances on my Notebook. That might get less in the future using Docker. Anyway to differentiate sites and sitecore instances I follow the pattern:

[sitecore_instance_prefix].[sitename].local e.g. 10sc.mysite.local

sitecore_instance_prefix

When installting sitecore instance you are creating a first DNS in your IIS so you can access the instance. This is usually following the pattern: [your_choice]sc.dev.local

I'm using the subdomain [your_choice]sc as [sitecore_instance_prefix]

 

sitename

The sitename is the name of the site that you have used when creating the site using the site creation wizard (that's a lot of "site"s in one sentence)

 

2. Put DNS is Host File

Using a Windows 10 machine you find your host file here: C:\Windows\System32\drivers\etc\hosts

Open the file in a text editor.

Add an entry: e.g. 127.0.0.1         10sc.mysite.local

 Save the file.

3. Setup Self Signed Certificate (for local)

Open IIS Manager

Select the Server node and doubleclick the "Server Certificates" button

2-1 Certificate

 

Under the Actions, click "Create Self-Signed Certificate"

2-2 Certificate

put in the DNS you are using for your site.

Select Personal.

2-3 Certificate

Submit pressing OK.

 

More information: https://docs.microsoft.com/en-us/iis/manage/configuring-security/how-to-set-up-ssl-on-iis#iis-manager

 Alternative: If you prefer the powershell way to create a certificate you find a script here: https://sitecore.stackexchange.com/questions/1224/how-do-you-setup-your-local-sitecore-instance-to-support-https-in-either-a-singl Make sure you open Powershell as Administrator!

4. Setup Bindings

Open IIS Manager.

Select the Site that represent your sitecore instance

And click on "Bindings" on the right side

3-1 Setup Binding

Click the "Add" button of the dialog

3-2 Setup Binding

 

 

 

4.1 HTTP Binding

If you want to add a http Binding, select Type http. The Port is set automatically to "80"

Add your Host name and submit pressing the "OK" button.

3-3-1 Setup Binding

4.2 HTTPS Binding

If you want to add a https Binding, select Type https. The port is set automatically to "443"

Add your Host name

 

Select the SSL Certificate you created in step 3 and submit pressing the "OK" button.

 

3-3-2 Setup Binding

 

5. Do site configuration in Site Definition item

When you have created your site already, navigate to sitecore/content/[your_tenant]/[your_site]/Settings/Site Grouping/[your_site]

Put the your DNS into the Host name field.

5-1 config

Save and publish the item, as well as your site if not yet done, as the site configuration in this case is used for web db (CD)

 

Note: You can pipe separate several DNSs to access your website and you can use "*" e.g. to reuse site configuration for each environment e.g. dev.mysite.com; pp.mysite.com; www.mysite.com --> *.mysite.com

The benefit of having the site config in the item is that the config change does not cause your instance to restart.

 

Created: 13.1.2021

SXA Multisite Sitecore Basics