Using placeholders in replace_response

1. Caddy version (caddy version):

v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=

2. How I run Caddy:

in a docker image

a. System environment:

ubuntu based docker image

b. Command:

caddy --config /etc/caddy/Caddyfile

c. Service/unit/compose file:

S6 running the command above

d. My complete Caddyfile or JSON config:

{
        order replace after encode
}

:80 {

        redir /subpath /subpath/
        route /subpath/* {
                uri strip_prefix /subpath
                replace {
                        http://example/(subpath/)?    {http.request.host}/subpath/
                }

                reverse_proxy {
                        to 127.0.0.1:8081
                        header_down Location (https?://)([^/]+)/(subpath/)? $2$3/subpath/
                        header_down Location ^/(subpath/)? /subpath/
                        header_up Access-Control-Allow-Origin '*'
                }
        }
}

3. The problem I’m having:

attempting to use {http.request.host} as part of the replacement in replace_response doesn’t use the placeholder. Instead it uses the literal string {http.request.host}

4. Error messages and/or full log output:

console error shows http

5. What I already tried:

just as above

6. Links to relevant resources:

n/a

You should open an issue on the replace-response plugin repo for this, since it’s a feature request.

will do! I wasn’t sure if it was supposed to be supported already - thank you!

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