Modifying reverse proxy response?
Can a CGI be fed the response from a reverse proxy, modify it , and spit out the modified response?
I tried this without success:
reverse_proxy {host}:443 {
header_up Host {upstream_hostport}
handle_response {
handle /some/path/i/want/to/override {
cgi * /scripts/hello.py {
pass_all_env
}
}
handle {
copy_response
}
}
}
That's an interesting problem. I'll try to reproduce that setup in the next days and see how far I can get. No promises yet 🙂
Thanks! :)
I looked into it a bit and also searched through documentation and the caddy forum, but from what I can tell, there is no way to access the body of the reverse_proxy response. If you are only interested in the headers, you could basically do, what forward_auth does, but as soon as you need the body, there doesn't seem to be any way. If I missed anything, please point me in the right direction, otherwise I think this cannot be accomplished (here; it would have to be a change request towards caddy).
Thanks for looking into it! I guess as a workaround I can pass the required cookies as ENV and do the reverse proxying step in the CGI
I think that would also be cleaner in general. You end up with a "proper" stream: client -> caddy -> cgi -> upstream.