Reverse_proxy dynamic_upstreams

1. Output of caddy version:

v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=

2. How I run Caddy:

a. System environment:

amazon linux 2

b. Command:

caddy run --config caddyfile.json

d. My complete Caddy config:

{
    "apps": {
        "http": {
            "servers": {
                "srv0": {
                    "listen": [
                        ":443",
                        ":80"
                    ],
                    "routes": [
                        {
                                {
                                "handler":"encode",
                                "encodings":{"gzip":{},"zstd":{}},
                                "prefer":["zstd","gzip"]
                                },
                                {
                                "handler": "reverse_proxy",
                                "dynamic_upstreams":
                                    {
                                    "source":"srv",
                                    "service":"_wg",
                                    "proto":"tcp",
                                    "name":"{host}",
                                    "refresh":"10m",
                                    "dial_timeout":"4s"
                                    },
                                }
                            ]
                        }
                    ],
                    "tls_connection_policies": [
                        {}
                    ]
                }
            }
        },
        "tls": {
            "automation": {
               "policies": [
                    {
                        "issuers": [
                            {
                                "email": "[redacted]",
                                "module": "acme"
                            },
                            {
                                "email": "[redacted],
                                "module": "zerossl"
                            }
                        ],
                        "on_demand": true
                    }
                ],
                "on_demand": {
                    "ask": "http://10.50.1.11/.check"
                }
            }
        }
    },
    "storage": {
        "module": "file_system",
        "root": "/var/caddy"
    }
}

3. The problem I’m having:

Host is not being resolved by composing the srv record request with service+proto+name when used with placeholder as name with error shown below:

2022/09/22 16:17:59.925 ERROR   http.handlers.reverse_proxy     failed getting dynamic upstreams; falling back to static upstreams      {"error": "lookup __wg._tcp. on 172.26.0.2:53: dial tcp 174.129.251.171:0: i/o timeout"}

4. Error messages and/or full log output:

2022/09/22 16:17:59.925 ERROR   http.handlers.reverse_proxy     failed getting dynamic upstreams; falling back to static upstreams      {"error": "lookup __wg._tcp. on 172.26.0.2:53: dial tcp 174.129.251.171:0: i/o timeout"}

5. What I already tried:

6. Links to relevant resources:

The correct placeholder is {http.request.host}{host} is only a Caddyfile shorthand.

Thanks that works. Perhaps a note on Caddyfile Concepts — Caddy Documentation indicating those only work in a caddyfile?

I thought that was obvious, given the page is called “Caddyfile Concepts”, but sure.

Is there a repo for the documentation that pull requests can be made from? The reason I got to that page is that is where all of the relevant “placeholders” appeared for http variables and the page lists the caddyfile ones alongside the others. The documentation menu on the left doesn’t include a “json placeholders” beneath the json config file but I do note the list appears on the http app settings within the json docs

The JSON config has its placeholders documented where the JSON config is documented: Modules - Caddy Documentation

That documentation is extracted directly from Caddy code comments. Since the JSON config is extensible and dynamic, we don’t have static links in our sidebar.

Caddyfile docs are written in markdown here: GitHub - caddyserver/website: The Caddy website

This topic was automatically closed after 30 days. New replies are no longer allowed.