You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that rewrite will only work in handle_response if copy_response_headers is set with the same variable that was used in the rewrite (i.e. X-Accel-Redirectmust be exposed downstream).
Instead of getting the files as expected, I get 404s.
+ copy_response_headers {+ include X-Accel-Redirect+ }
rewrite * {http.response.header.X-Accel-Redirect}
I stumbled upon the workaround because I was using copy_response_headers to debug and sanity check that the header I was setting was being seen by Caddy.
Then the rewrite suddenly started working.
I take that away and it 404s again.
Additionally, I can't use header_down -X-Accel-Redirect to get rid of the of copied header.
My bet is that the priority of when http.response.header.Whatever is set has changed such that it refers to the final headers to the Caddy client rather than the intermediary headers from the reverse proxy.
copy_response_headers causes the header to be set before rewrite takes place.
I suppose that the priority currently is:
header_down hence causes neither failure nor removes the header
copy_response_headers makes the header available to rewrite
rewrite can't access the response header if it hasn't been copied to the response
Full Caddyfile
I doubt the other directives I have are at play since I've identified exactly which change works and fails, but just in case there's a strange interaction, this is very, very close to my actual Caddyfile:
Caddy v2.7.6
It seems that
rewrite
will only work inhandle_response
ifcopy_response_headers
is set with the same variable that was used in the rewrite (i.e.X-Accel-Redirect
must be exposed downstream).Instead of getting the files as expected, I get 404s.
I stumbled upon the workaround because I was using
copy_response_headers
to debug and sanity check that the header I was setting was being seen by Caddy.Then the rewrite suddenly started working.
I take that away and it 404s again.
Additionally, I can't use
header_down -X-Accel-Redirect
to get rid of the of copied header.Failing
Workaround
Best Guess
My bet is that the priority of when
http.response.header.Whatever
is set has changed such that it refers to the final headers to the Caddy client rather than the intermediary headers from the reverse proxy.copy_response_headers
causes the header to be set before rewrite takes place.I suppose that the priority currently is:
header_down
hence causes neither failure nor removes the headercopy_response_headers
makes the header available torewrite
rewrite
can't access the response header if it hasn't been copied to the responseFull Caddyfile
I doubt the other directives I have are at play since I've identified exactly which change works and fails, but just in case there's a strange interaction, this is very, very close to my actual Caddyfile:
Originally Documented Behavior
The original PR showed this example:
That no longer works.
References
Keywords: X-Accel-Redirect, X-Sendfile, X-LIGHTTPD-send-file
Ref:
handle_response
blocks toreverse_proxy
(#3710) #4021The text was updated successfully, but these errors were encountered: