Caddy v2 reverse_proxy rewrite headers with header_up

1. My Caddy version (caddy version):

v2.0.0-beta9

2. How I run Caddy:

./caddy run -config Caddyfile

https://svn.example.com {
  #log /opt/caddy/logs/log.log
  #errors /opt/caddy/logs/errors.log
  reverse_proxy / 192.168.1.100:8088 {
    header_up SuperstarHeader SuperstarValue
    header_up OriginalDestination {http.request.header.Destination}
    header_up OriginalConnection {http.request.header.Connection}
    header_up +Destination  "https://svn.example.com(.*)" "http://192.168.1.100:8088/$1"
  }
  tls /opt/caddy/certs/svn.example.com.crt /opt/caddy/certs/svn.example.com.key
}

3. The problem I’m having:

I upgraded my caddy version to v2 for testing http 502 - caddy proxies to svn server · Issue #2018 · caddyserver/caddy · GitHub

The header_up does not work with {http.request.header.*} placeholders.
The headers are present but empty.

Whats the v2 statement for

header_upstream Destination "https://svn.example.com(.*)" "http://192.168.1.100:8088/$1"

to set the Destination header correctly?

4. Error messages and/or full log output:

The header SuperstarHeader is present with correct value :slight_smile:
The headers OriginalDestination and OriginalConnection are present but empty.
The Destination header is not present

5. What I already tried:

crying in bed alone

6. Links to relevant resources:

http 502 - caddy proxies to svn server · Issue #2018 · caddyserver/caddy · GitHub

2 Likes

Thanks for trying v2!

I just tried with your config, and it works fine. Obviously, the client needs to send those headers in the request or it will be empty. When they are set, your config sets them properly.

(Is that even a valid v1 statement?)

It sounds like you want to append the request path to the Destination header, so:

header_up Destination "http://192.168.1.100:8088{path}"

Should do the trick.

PS. Use v2 beta 11, which was released last week.

It is, yes:

https://github.com/caddyserver/caddy/pull/2144

(Seems it shall remain forever undocumented, heh)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.