Unable to use port as an argument in a matcher

1. The problem I’m having:

I have a backend device that only accepts one connection at a time, so I’m trying to setup an internal proxy to “front” connections to this device. I need to proxy 3 ports: 80, 3030, and 3031.

When I restart caddy using the configuration file specified in “My Complete Caddy Config”, I get:

Error: adapting config using caddyfile: ambiguous site definition: http://172.30.1.23:{args[0]}

So, it appears that snippet is being parsed twice (once for each import) and caddy thinks the definition is being ambiguous.

If I remove the import lines with port 3030 and 3031, everything works.

How can I do something like this without repeating the entire configuration?

3. Caddy version:

2.6.2

4. How I installed and ran Caddy:

sudo apt install caddy

a. System environment:

Debian bookwork, running caddy from systemd.

b. Command:

systemctl restart caddy

c. Service/unit/compose file:

N/A

d. My complete Caddy config:

(centauri_proxy) {
    http://172.30.1.23:{args[0]}, http://eccproxy:{args[0]}, http://eccproxy.lan:{args[0]} {
        log {
            output stdout
            format json
            level info
        }

        reverse_proxy centauri-carbon.lan:{args[0]}  {
            transport http {
                # Use HTTP/2 for proper multiplexing.
                versions h2

                # Only one connection per host. The centauri carbon
                # has a limited number of simultaneous connections.
                max_conns_per_host 1

                # Keep the connection alive
                keepalive 2m
                keepalive_idle_conns_per_host 1
            }
        }
    }
}

# Instantiate the proxy configs.
import centauri_proxy 80
import centauri_proxy 3030
import centauri_proxy 3031