replace-response icon indicating copy to clipboard operation
replace-response copied to clipboard

How to replace the content in websock

Open abcdsxg opened this issue 4 years ago • 2 comments

My caddyfile

a.com {
    import log
    reverse_proxy b.com {
        header_up Accept-Encoding identity
        header_up Host {upstream_hostport}
        header_up X-Forwarded-Host {host}
    }

    replace {
        foo bar
    }
}

It didn't work

abcdsxg avatar Nov 30 '21 08:11 abcdsxg

I think that's currently unsupported. I don't think it's possible either, unfortunately, without changes to the reverse_proxy module. Once the HTTP protocol upgrade to Websockets is performed, it becomes a direct bidirectional buffer copy with no opportunity to intercept the messages.

francislavoie avatar Nov 30 '21 12:11 francislavoie

Hmm, yeah, I have no idea how to do this. Would require some clever, careful design work to allow other plugins to intercept the hijacked conn in the reverse proxy and inspect all the bytes flowing through as a stream.

mholt avatar Dec 02 '21 18:12 mholt