1. Caddy version (caddy version
):
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
a. System environment:
Debian 10.2, Docker version 20.10.10, build b485636
b. Command:
caddy run
c. Service/unit/compose file:
docker run --name caddy --net=host -e TZ=Asia/Shanghai -e GO111MODULE=on -e GOPROXY=https://goproxy.cn,direct --restart=always -v /data/www:/data/www:ro -v /etc/caddy:/etc/caddy:ro -v /var/log/caddy:/log -w /etc/caddy -d caddy:builder-alpine sh -c "if [ ! -x /usr/bin/caddy ]; then xcaddy build --output /usr/bin/caddy --with github.com/caddyserver/format-encoder; fi; caddy run"
d. My complete Caddyfile or JSON config:
reverse_proxy http://127.0.0.1:3690 {
header_down -Server
header_down Location ^http:// {http.request.scheme}://
header_down Refresh ^http:// {http.request.scheme}://
transport http {
keepalive 60s
}
@auth status 401
handle_response @auth {
header WWW-Authenticate {http.reverse_proxy.header.WWW-Authenticate}
respond "" {http.reverse_proxy.status_code}
}
}
3. The problem Iām having:
curl -v "http://localhost/test"
* Trying 82.157.162.166...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /test HTTP/1.1
> Host: localhost
> User-Agent: curl/7.59.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Server: nginx
< Www-Authenticate:
< Date: Fri, 19 Nov 2021 03:18:04 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
I use caddy to reverse proxy apache svn server, and hide the return information of apache.
But Www-Authenticate in headers is empty.
4. Error messages and/or full log output:
5. What I already tried:
I change respond to
respond {http.reverse_proxy.header.WWW-Authenticate} {http.reverse_proxy.status_code}
or
respond {http.reverse_proxy.header.Host} {http.reverse_proxy.status_code}
will return original text , not the corresponding value of the placeholder.