diff --git a/tests/data/conf.in b/tests/data/conf.in
index d5ed59a012b936f1b226235bf5ad35512be1881e..d46d1a1f4013b03a653f7c0eeeb18d47a7140c96 100644
--- a/tests/data/conf.in
+++ b/tests/data/conf.in
@@ -1,3 +1,3 @@
 [general]
-url=http://127.0.0.1:1234/versions/@SYSROOT@
+url=http://HOST/versions/@SYSROOT@
 
diff --git a/tests/data/invalid_archive.in b/tests/data/invalid_archive.in
index 29a060705cc614bcf9a231ca16bbd5583b27c05c..4f9db727b2bc38fc39387037b52b1461143ec0dd 100644
--- a/tests/data/invalid_archive.in
+++ b/tests/data/invalid_archive.in
@@ -1,2 +1,2 @@
 version=16.09 20161101.0
-url=http://127.0.0.1:1234/archives/eraroj-16.09-armhf_invalidarchive.tar.gz
+url=http://HOST/archives/eraroj-16.09-armhf_invalidarchive.tar.gz
diff --git a/tests/data/invalid_sysroot.in b/tests/data/invalid_sysroot.in
index 504517d38ee7b6a06db1e84b68e9f879e60f7e45..7fbcea3398c46e0bbf54c752b85dd403f1d48242 100644
--- a/tests/data/invalid_sysroot.in
+++ b/tests/data/invalid_sysroot.in
@@ -1,2 +1,2 @@
 version=16.09 20161101.0
-url=http://127.0.0.1:1234/archives/eraroj-16.09-armhf_invalidversion.tar.gz
+url=http://HOST/archives/eraroj-16.09-armhf_invalidversion.tar.gz
diff --git a/tests/data/invalid_version.in b/tests/data/invalid_version.in
index c623d3959af72451fdc01b0980fd5468b98c6b02..ad9ce7dcb26744aee8de4110586c32b41e79b39b 100644
--- a/tests/data/invalid_version.in
+++ b/tests/data/invalid_version.in
@@ -1,2 +1,2 @@
 version=20161101.0
-url=http://127.0.0.1:1234/data/sysroot-apertis-16.09-arm64_20161101.0.tar.gz
+url=http://HOST/data/sysroot-apertis-16.09-arm64_20161101.0.tar.gz
diff --git a/tests/data/latest.conf.in b/tests/data/latest.conf.in
index 57a406036c82d7331fb2c5462e4bedb04642a7cb..33727f0bd78a6a3c08ff2ccee3cec1642635e35a 100644
--- a/tests/data/latest.conf.in
+++ b/tests/data/latest.conf.in
@@ -1,3 +1,3 @@
 [general]
-url=http://127.0.0.1:1234/versions/%(distro)-%(release)-%(arch)_latest
+url=http://HOST/versions/%(distro)-%(release)-%(arch)_latest
 
diff --git a/tests/data/missing_version.in b/tests/data/missing_version.in
index 7eb59a66678868d6ff9bda15a04c27b950e19671..1cb24fc8a39f2672c6884652409870245857ec79 100644
--- a/tests/data/missing_version.in
+++ b/tests/data/missing_version.in
@@ -1 +1 @@
-url=http://127.0.0.1:1234/data/sysroot-apertis-16.09-arm64_20161101.0.tar.gz
+url=http://HOST/data/sysroot-apertis-16.09-arm64_20161101.0.tar.gz
diff --git a/tests/data/sections.conf.in b/tests/data/sections.conf.in
index 2e326a4e632e16cdfac6fa2dabd60aed2881f7d4..18adcd597d01339dd93af3bff7e786cf2a29f6d9 100644
--- a/tests/data/sections.conf.in
+++ b/tests/data/sections.conf.in
@@ -2,10 +2,10 @@
 url=http://example.com/sysroot
 
 [apertis]
-url=http://127.0.0.1:1234/versions/apertis-%(release)-%(arch)_latest
+url=http://HOST/versions/apertis-%(release)-%(arch)_latest
 
 [babiladis]
-url=http://127.0.0.1:1234/versions/babiladis-%(release)-%(arch)_latest
+url=http://HOST/versions/babiladis-%(release)-%(arch)_latest
 
 [fermis]
-url=http://127.0.0.1:1234/versions/fermis-%(release)-%(arch)_latest
+url=http://HOST/versions/fermis-%(release)-%(arch)_latest
diff --git a/tests/data/version.in b/tests/data/version.in
index 55f7a34360350fbe8ef03e24aaffa3d92635c096..0553e02b618ba0f15d306c2fed726896ac21c8f1 100644
--- a/tests/data/version.in
+++ b/tests/data/version.in
@@ -1,2 +1,2 @@
 version=@RELEASE@ @BUILD@
-url=http://127.0.0.1:1234/archives/@DISTRO@-@RELEASE@-@ARCH@_@BUILD@.tar.gz
+url=http://HOST/archives/@DISTRO@-@RELEASE@-@ARCH@_@BUILD@.tar.gz
diff --git a/tests/data/wrong_distro.in b/tests/data/wrong_distro.in
index 35d06980e52f6beb87c00870f932ca8e52235317..36a2fdc35d9a5d4bf981609f07d43152ca41051b 100644
--- a/tests/data/wrong_distro.in
+++ b/tests/data/wrong_distro.in
@@ -1,2 +1,2 @@
 version=16.09 20161101.0
-url=http://127.0.0.1:1234/archives/apertis-16.09-armhf_20161101.0.tar.gz
+url=http://HOST/archives/apertis-16.09-armhf_20161101.0.tar.gz
diff --git a/tests/data/wrong_release.in b/tests/data/wrong_release.in
index 82d3aecc5135ab08b723728902c9efb2f429884f..f4ecf4fea21f83ecf53a75c4c66580dc8d84be5e 100644
--- a/tests/data/wrong_release.in
+++ b/tests/data/wrong_release.in
@@ -1,2 +1,2 @@
 version=16.09 20161101.0
-url=http://127.0.0.1:1234/archives/eraroj-16.12-armhf_20161101.0.tar.gz
+url=http://HOST/archives/eraroj-16.12-armhf_20161101.0.tar.gz
diff --git a/tests/test-download b/tests/test-download
index 631116fdd81a924eab3c6541fb387675c3f29452..eb64a3211016ad1d82c3edc2526c6d3bad668e4e 100755
--- a/tests/test-download
+++ b/tests/test-download
@@ -13,8 +13,9 @@ import os
 import tempfile
 
 from test_util import SysrootServer
+from test_util import templatedconfig
 from test_util import should_succeed, should_fail
-from test_util import BASE_URL, BASE_ARCHIVE, BASE_CONFIG, \
+from test_util import BASE_ARCHIVE, BASE_CONFIG, \
                       SYSROOTS, LATEST_SYSROOTS, \
                       CONFIG_FILES, BAD_URLS
 
@@ -33,7 +34,7 @@ server.start()
 # Test "ade sysroot download --url" usage
 for sysroot in SYSROOTS:
     with tempfile.TemporaryDirectory() as tmpdir:
-        params = ['--url', BASE_URL.format(*sysroot), '--distro', sysroot[0],
+        params = ['--url', server.base_url().format(*sysroot), '--distro', sysroot[0],
                   '--release', sysroot[1], '--arch', sysroot[2]]
         should_succeed('download', *params, path=tmpdir,
                        check=lambda x: check_archive(x, sysroot))
@@ -41,22 +42,24 @@ for sysroot in SYSROOTS:
 # Test "ade sysroot download --distro --release --arch" usage
 for sysroot in SYSROOTS:
     with tempfile.TemporaryDirectory() as tmpdir:
-        params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
-        should_succeed('download', *params, config=BASE_CONFIG.format(*sysroot), path=tmpdir,
-                       check=lambda x: check_archive(x, sysroot))
+        with templatedconfig(server, BASE_CONFIG.format(*sysroot)) as config:
+            params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
+            should_succeed('download', *params, config=config, path=tmpdir,
+                            check=lambda x: check_archive(x, sysroot))
 
 # Test "ade sysroot download --distro --release --arch" usage with different config files
 for config_file in CONFIG_FILES:
-    config = os.path.join(os.getcwd(), "configs", config_file)
-    for sysroot in LATEST_SYSROOTS:
-        with tempfile.TemporaryDirectory() as tmpdir:
-            params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
-            should_succeed('download', *params, config=config, path=tmpdir,
-                           check=lambda x: check_archive(x, sysroot))
+    with templatedconfig(server, config_file) as config:
+        for sysroot in LATEST_SYSROOTS:
+            with tempfile.TemporaryDirectory() as tmpdir:
+                params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
+                should_succeed('download', *params, config=config, path=tmpdir,
+                               check=lambda x: check_archive(x, sysroot))
 
 # Test error cases
 with tempfile.TemporaryDirectory() as tmpdir:
     for url in BAD_URLS:
+        url.replace("HOST", server.host())
         params = ['--url', url, '--distro', 'eraroj', '--release', '16.09', '--arch', 'armhf']
         should_fail('download', *params, path=tmpdir)
 
diff --git a/tests/test-install b/tests/test-install
index 02bdda5065f0148009f4047a91b5a7b2e2303783..b4aa011a8b809c58f19b635669e9aa2d7302b1b8 100755
--- a/tests/test-install
+++ b/tests/test-install
@@ -13,8 +13,9 @@ import os
 import tempfile
 
 from test_util import SysrootServer
+from test_util import templatedconfig
 from test_util import should_succeed, should_fail
-from test_util import BASE_TAG, BASE_URL, BASE_ARCHIVE, BASE_CONFIG, \
+from test_util import BASE_TAG, BASE_ARCHIVE, BASE_CONFIG, \
                       SYSROOTS, LATEST_SYSROOTS, SYSROOT1, SYSROOT2, \
                       CONFIG_FILES, BAD_URLS
 
@@ -39,7 +40,7 @@ server.start()
 # Test "ade sysroot install --url" usage
 for sysroot in SYSROOTS:
     with tempfile.TemporaryDirectory() as tmpdir:
-        params = ['--url', BASE_URL.format(*sysroot), '--distro', sysroot[0],
+        params = ['--url', server.base_url().format(*sysroot), '--distro', sysroot[0],
                   '--release', sysroot[1], '--arch', sysroot[2]]
         should_succeed('install', *params, path=tmpdir,
                        check=lambda x: check_sysroot(x, tmpdir, sysroot))
@@ -53,19 +54,20 @@ for sysroot in SYSROOTS:
 # Test "ade sysroot install --distro --release --arch" usage
 for sysroot in SYSROOTS:
     with tempfile.TemporaryDirectory() as tmpdir:
-        params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
-        should_succeed('install', *params, config=BASE_CONFIG.format(*sysroot), path=tmpdir,
-                       check=lambda x: check_sysroot(x, tmpdir, sysroot))
-
-# Test "ade sysroot install --distro --release --arch" usage with different config files
-for config_file in CONFIG_FILES:
-    config = os.path.join(os.getcwd(), "configs", config_file)
-    for sysroot in LATEST_SYSROOTS:
-        with tempfile.TemporaryDirectory() as tmpdir:
+        with templatedconfig(server, BASE_CONFIG.format(*sysroot)) as config:
             params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
             should_succeed('install', *params, config=config, path=tmpdir,
                            check=lambda x: check_sysroot(x, tmpdir, sysroot))
 
+# Test "ade sysroot install --distro --release --arch" usage with different config files
+for config_file in CONFIG_FILES:
+    with templatedconfig(server, config_file) as config:
+        for sysroot in LATEST_SYSROOTS:
+            with tempfile.TemporaryDirectory() as tmpdir:
+                params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
+                should_succeed('install', *params, config=config, path=tmpdir,
+                               check=lambda x: check_sysroot(x, tmpdir, sysroot))
+
 # Test "ade sysroot install --force" usage
 with tempfile.TemporaryDirectory() as tmpdir:
     should_succeed('install', '--file', BASE_ARCHIVE.format(*SYSROOT1), path=tmpdir,
diff --git a/tests/test-latest b/tests/test-latest
index 3394ad73e2d81c0c8574ea1c219b23cf2b5a61d4..878ef3ed1f1cc96ac5b3f060bb1419da1f9fe06b 100755
--- a/tests/test-latest
+++ b/tests/test-latest
@@ -12,8 +12,9 @@
 import os
 
 from test_util import SysrootServer
+from test_util import templatedconfig
 from test_util import should_succeed, should_fail
-from test_util import BASE_TAG, BASE_URL, BASE_ARCHIVE, BASE_CONFIG, \
+from test_util import BASE_TAG, BASE_ARCHIVE, BASE_CONFIG, \
                       SYSROOTS, LATEST_SYSROOTS, \
                       CONFIG_FILES, BAD_VERSION_URLS
 
@@ -28,25 +29,26 @@ server.start()
 
 # Test "ade sysroot latest --url" usage
 for sysroot in SYSROOTS:
-    params = ['--url', BASE_URL.format(*sysroot), '--distro', sysroot[0],
+    params = ['--url', server.base_url().format(*sysroot), '--distro', sysroot[0],
               '--release', sysroot[1], '--arch', sysroot[2]]
     should_succeed('latest', *params,
                    check=lambda x: check_version(x, sysroot))
 
 # Test "ade sysroot latest --distro --release --arch" usage
 for sysroot in SYSROOTS:
-    params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
-    should_succeed('latest', *params, config=BASE_CONFIG.format(*sysroot),
-                   check=lambda x: check_version(x, sysroot))
-
-# Test "ade sysroot latest --distro --release --arch" usage with different config files
-for config_file in CONFIG_FILES:
-    config = os.path.join(os.getcwd(), "configs", config_file)
-    for sysroot in LATEST_SYSROOTS:
+    with templatedconfig(server, BASE_CONFIG.format(*sysroot)) as config:
         params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
         should_succeed('latest', *params, config=config,
                        check=lambda x: check_version(x, sysroot))
 
+# Test "ade sysroot latest --distro --release --arch" usage with different config files
+for config_file in CONFIG_FILES:
+    with templatedconfig(server, config_file) as config:
+        for sysroot in LATEST_SYSROOTS:
+            params = ['--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
+            should_succeed('latest', *params, config=config,
+                           check=lambda x: check_version(x, sysroot))
+
 # Test error cases
 for url in BAD_VERSION_URLS:
     params = ['--url', url, '--distro', 'eraroj', '--release', '16.09', '--arch', 'armhf']
diff --git a/tests/test-update b/tests/test-update
index 5393c99eb77686cd1169a0d40d2718c6e00e0acd..01785c02524fb8f42731c3cbe07e68fb21d80a5d 100755
--- a/tests/test-update
+++ b/tests/test-update
@@ -13,8 +13,9 @@ import os
 import tempfile
 
 from test_util import SysrootServer
+from test_util import templatedconfig
 from test_util import should_succeed, should_fail
-from test_util import BASE_TAG, BASE_URL, BASE_ARCHIVE, BASE_CONFIG, \
+from test_util import BASE_TAG, BASE_ARCHIVE, BASE_CONFIG, \
                       SYSROOTS, LATEST_SYSROOTS, SYSROOT1, SYSROOT2, \
                       SYSROOT_VERSIONS, CONFIG_FILES, BAD_URLS
 
@@ -33,7 +34,7 @@ def check_sysroot(result, path, sysroot):
     return check_result(result, sysroot) and check_install(path, sysroot)
 
 def install_initial_release(path):
-    params = ['--url', BASE_URL.format(*SYSROOT1), '--distro', SYSROOT1[0],
+    params = ['--url', server.base_url().format(*SYSROOT1), '--distro', SYSROOT1[0],
               '--release', SYSROOT1[1], '--arch', SYSROOT1[2]]
     should_succeed('install', *params, path=path)
 
@@ -45,30 +46,31 @@ server.start()
 with tempfile.TemporaryDirectory() as tmpdir:
     install_initial_release(tmpdir)
     for sysroot in SYSROOT_VERSIONS:
-        params = ['--url', BASE_URL.format(*sysroot),
+        params = ['--url', server.base_url().format(*sysroot),
                   '--distro', sysroot[0], '--release', sysroot[1], '--arch', sysroot[2]]
         should_succeed('update', *params, path=tmpdir,
                        check=lambda x: check_sysroot(x, tmpdir, sysroot))
 
 # Test "ade sysroot update --distro --release --arch" usage
 with tempfile.TemporaryDirectory() as tmpdir:
-    install_initial_release(tmpdir)
-    params = ['--distro', SYSROOT2[0], '--release', SYSROOT2[1], '--arch', SYSROOT2[2]]
-    should_succeed('update', *params, config=BASE_CONFIG.format(*SYSROOT2), path=tmpdir,
-                   check=lambda x: check_sysroot(x, tmpdir, SYSROOT2))
+    with templatedconfig(server, BASE_CONFIG.format(*SYSROOT2)) as config:
+        install_initial_release(tmpdir)
+        params = ['--distro', SYSROOT2[0], '--release', SYSROOT2[1], '--arch', SYSROOT2[2]]
+        should_succeed('update', *params, config=config, path=tmpdir,
+                       check=lambda x: check_sysroot(x, tmpdir, SYSROOT2))
 
 # Test "ade sysroot update --distro --release --arch" usage with different config files
 for config_file in CONFIG_FILES:
     with tempfile.TemporaryDirectory() as tmpdir:
         install_initial_release(tmpdir)
-        config = os.path.join(os.getcwd(), "configs", config_file)
-        params = ['--distro', SYSROOT2[0], '--release', SYSROOT2[1], '--arch', SYSROOT2[2]]
-        should_succeed('update', *params, config=config, path=tmpdir,
-                       check=lambda x: check_sysroot(x, tmpdir, SYSROOT2))
+        with templatedconfig(server, config_file) as config:
+            params = ['--distro', SYSROOT2[0], '--release', SYSROOT2[1], '--arch', SYSROOT2[2]]
+            should_succeed('update', *params, config=config, path=tmpdir,
+                           check=lambda x: check_sysroot(x, tmpdir, SYSROOT2))
 
 # Test "ade sysroot update --force" usage
 with tempfile.TemporaryDirectory() as tmpdir:
-    params = ['--url', BASE_URL.format(*SYSROOT2), '--distro', SYSROOT2[0],
+    params = ['--url', server.base_url().format(*SYSROOT2), '--distro', SYSROOT2[0],
               '--release', SYSROOT2[1], '--arch', SYSROOT2[2]]
 
     # Trying to update non-installed sysroot
@@ -91,7 +93,7 @@ with tempfile.TemporaryDirectory() as tmpdir:
         if not os.path.exists(stamp.name):
             exit(1)
 
-    params = ['--url', BASE_URL.format(*SYSROOT1), '--distro', SYSROOT1[0],
+    params = ['--url', server.base_url().format(*SYSROOT1), '--distro', SYSROOT1[0],
               '--release', SYSROOT1[1], '--arch', SYSROOT1[2]]
 
     # Try to downgrade to older version
diff --git a/tests/test_util.py b/tests/test_util.py
index fbfe1f5b1fe727d1f9a889cad44b446af7f99fa1..76dafccb8c8f21be8a7cc3bfe40912460243aa06 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -13,9 +13,13 @@ import os
 import socket
 import subprocess
 import threading
+import tempfile
+import shutil
+import atexit
+from pathlib import Path
+from contextlib import contextmanager
 
 BASE_TAG = "{0}-{1}-{2}_{3}"
-BASE_URL = "http://127.0.0.1:1234/versions/{0}".format(BASE_TAG)
 BASE_ARCHIVE = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files', 'archives', "{0}.tar.gz".format(BASE_TAG))
 BASE_CONFIG  = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files', 'configs', "{0}.conf".format(BASE_TAG))
 BASE_INSTALL  = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files', 'install')
@@ -68,18 +72,18 @@ CONFIG_FILES = [
 
 BAD_VERSION_URLS = [
     'invalidformat',
-    'http://127.0.0.1:1234/not_found',
-    'http://127.0.0.1:1234/versions/empty',
-    'http://127.0.0.1:1234/versions/missing_version',
-    'http://127.0.0.1:1234/versions/missing_url',
-    'http://127.0.0.1:1234/versions/invalid_version'
+    'http://HOST/not_found',
+    'http://HOST/versions/empty',
+    'http://HOST/versions/missing_version',
+    'http://HOST/versions/missing_url',
+    'http://HOST/versions/invalid_version'
 ]
 
 BAD_SYSROOT_URLS = [
-    'http://127.0.0.1:1234/versions/wrong_distro',
-    'http://127.0.0.1:1234/versions/wrong_release',
-    'http://127.0.0.1:1234/versions/invalid_archive',
-    'http://127.0.0.1:1234/versions/invalid_sysroot'
+    'http://HOST/versions/wrong_distro',
+    'http://HOST/versions/wrong_release',
+    'http://HOST/versions/invalid_archive',
+    'http://HOST/versions/invalid_sysroot'
 ]
 
 BAD_URLS = BAD_VERSION_URLS + BAD_SYSROOT_URLS
@@ -130,14 +134,39 @@ class SysrootHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
     def log_message(self, *args):
         pass
 
+def template_config_file(server, src, dst):
+    with open(src) as fsrc:
+        host = "{}:{}".format(*server.server_address)
+        output = []
+        for line in fsrc.readlines():
+            output.append((line.replace("HOST", host)))
+
+    with open(dst, 'w') as fdst:
+        fdst.writelines(output)
+
 class SysrootServer(http.server.HTTPServer):
     def __init__(self):
-        os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files'))
-        super().__init__(("", 1234), SysrootHTTPRequestHandler)
+        contentdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+                                  'files')
+        tmpdir = tempfile.TemporaryDirectory()
+        atexit.register (tmpdir.cleanup)
+
+        self.tmpcontentdir = os.path.join(tmpdir.name, 'files')
+        shutil.copytree(contentdir, self.tmpcontentdir)
+        os.chdir(self.tmpcontentdir)
+
+        # This binds so we can determine the port that's used
+        super().__init__(("127.0.0.1", 0), SysrootHTTPRequestHandler)
+
+        for f in Path(self.tmpcontentdir).rglob("versions/*"):
+            template_config_file (self, f.as_posix(), f.as_posix())
+
+        for f in Path(self.tmpcontentdir).rglob("configs/*"):
+            template_config_file (self, f.as_posix(), f.as_posix())
 
     def server_bind(self):
         self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-        self.socket.bind(self.server_address)
+        super().server_bind()
 
     def start(self):
         self.thread = threading.Thread(target=self.serve_forever)
@@ -147,3 +176,19 @@ class SysrootServer(http.server.HTTPServer):
     def stop(self):
         self.shutdown()
         self.thread.join()
+
+    def host(self):
+        return "{}:{}".format(*self.server_address)
+
+    def base_url(self):
+        url = "http://{}/versions/{}"
+        return url.format(self.host(), BASE_TAG)
+
+@contextmanager
+def templatedconfig(server, config_file):
+    config = os.path.join(os.getcwd(), "configs", config_file)
+    with tempfile.TemporaryDirectory() as t:
+        tmpconfig = os.path.join(t, os.path.basename(config_file))
+
+        template_config_file(server, config, tmpconfig)
+        yield tmpconfig