1. Output of caddy version
:
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=
2. How I run Caddy:
./caddy run --config Caddyfile.dingyu --watch
a. System environment:
Ubuntu 20.04.5 LTS (Focal Fossa)
b. Command:
./caddy run --config Caddyfile.dingyu --watch
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->
d. My complete Caddy config:
v.dingyu.me {
tls felixding@gmail.com
#reverse_proxy /contact localhost:446
handle_path /contact {
reverse_proxy localhost:446
}
log {
level INFO
}
}
3. The problem Iām having:
Iām trying to use Caddy as a reverse proxy. All is fine except one thing: the size
and status
in the response headers are always 0
, even though the traffic was successfully tunneled by Caddy and the upstream proxy server.
I need to know the correct status and size for my app to work, therefore this is a critical issue for me.
4. Error messages and/or full log output:
2022/11/20 10:28:59.935 INFO http.log.access.log0 handled request "2022/11/20 10":"28":59.935 INFO http.log.access.log0 handled request{
"request":{
"remote_ip":"27.141.195.16",
"remote_port":"53393",
"proto":"HTTP/1.1",
"method":"GET",
"host":"v.dingyu.me",
"uri":"/contact",
"headers":{
"Sec-Websocket-Key":[
"6+aYCXzXqLVLWpO7rv3S7Q=="
],
"Sec-Websocket-Version":[
"13"
],
"Upgrade":[
"websocket"
],
"User-Agent":[
"Go-http-client/1.1"
],
"Connection":[
"Upgrade"
]
},
"tls":{
"resumed":false,
"version":772,
"cipher_suite":4865,
"proto":"http/1.1",
"server_name":"v.dingyu.me"
}
},
"user_id":"",
"duration":1.082072341,
"size":0,
"status":0,
"resp_headers":{
"Server":[
"Caddy"
],
"Alt-Svc":[
"h3=\":443\"; ma=2592000"
],
"Connection":[
"Upgrade"
],
"Sec-Websocket-Accept":[
"nuPVZTIVT4AqyTXk9ahp7jnp/Ns="
],
"Upgrade":[
"websocket"
]
}
}
5. What I already tried:
I tried adding header_up Host {upstream_hostport}
, header_up Host {http.reverse_proxy.upstream.host} and header_up Host {http.reverse_proxy.upstream.hostport}
to reverse_proxy
but nothing worked.
I tried Nginx which can return the correct status and size from the upstream proxy server so I think the upstream settings are fine.
I tried Caddy ā (reverse proxy) ā Nginx ā (reverse proxy) ā the upstream proxy server. Strangely this time it returned 0 both size and status.
6. Links to relevant resources:
I have read this thread a few times and tried everything I could think of but got nowhere.