# How to replicate a dynamic config for many domains?

**URL:** <https://community.traefik.io/t/how-to-replicate-a-dynamic-config-for-many-domains/19792>\
**Category:** Traefik v2\
**Tags:** docker, file\
**Created:** [September 11, 2023, 2:05am UTC](https://community.traefik.io/t/how-to-replicate-a-dynamic-config-for-many-domains/19792 "2023-09-11T02:05:40Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![shot](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/shot/32/2312_2.png) [@shot](https://community.traefik.io/u/shot)\
**Post date:** [September 12, 2023, 2:29pm UTC](https://community.traefik.io/t/how-to-replicate-a-dynamic-config-for-many-domains/19792/6 "2023-09-12T14:29:19Z")

</div>

Thanks. Yes, I read the docs (as well as most template-related forum posts) before posting my message here. My main question was how to supply the data used by the template, and how to do so in a dynamic (eventually automated) way.

So I did eventually work out one approach using **Go** templating `dict` types, as shown below.

#### The following template...

```auto
{{ $proxies := list

	(dict "Domain" "hostdomain1.com"
  		  "Server" "backendserver1.com")

	(dict "Domain" "hostdomain2.com" 
  		  "Server" "backendserver2.com")
}}

http:
	services:
	{{range $proxies}}
		{{.Domain | replace "." "_"}}_svc:
			loadBalancer:
				servers:
					- url: https://{{.Server}}
	{{end}}

```

#### ...will result in the following output...

```auto
http:
	services:
	
		hostdomain1_com_svc:
			loadBalancer:
				servers:
					- url: https://backendserver1.com
	
		hostdomain2_com_svc:
			loadBalancer:
				servers:
					- url: https://backendserver2.com

```

Being entirely unfamiliar with **Go** , it actually took much more time than anticipated to get the syntax right. The following template playground tool was absolutely invaluable in working out the kinks...

- 
### [repeatit.io](https://repeatit.io/)

&nbsp;  
There's nothing like instantaneous real-time feedback when you're experimenting - especially in unfamiliar terrain. Kudos to the devs who put that together! 👍

Anyway, for now, I can simply update the YAML template with relevant data in order to add new services. Yippee!

😃

---

_[View the full topic](https://community.traefik.io/t/how-to-replicate-a-dynamic-config-for-many-domains/19792)._
