I am facing some issues with the Caddy proxy directive. My headers are all messed up and some wont appear on any request.
demo.raggaer.pw { tls [email protected] proxy / { header_upstream Host {>Host} header_upstream X-Real-IP {remote} header_upstream X-Forwarded-For {remote} header_upstream X-Forwarded-Proto {scheme} }
}I would expect to see those headers on the chrome console. I dont. Also all header keys are lowercase, is this something bad?
1 Answer
From the Caddy docs:
header_upstream sets headers to be passed to the backend.
The headers you set with this directive are not visible to Chrome. When Chrome makes the request, it sends its own set of headers to Caddy. With the header_upstream directive, Caddy can add its own headers to the ones from Chrome. The backend server (in your case ) can see both sets of headers, but Chrome has no idea that Caddy did anything.
Also, you'll probably want to use {host} instead of {>Host}. It's likely a little more reliable that way.
Finally, the reason you're seeing lowercase header keys is because Chrome is communicating with Caddy using HTTP/2, in which all header keys are lowercased. From the HTTP/2 spec:
Header field names MUST be converted to lowercase prior to their encoding in HTTP/2.