Is it possible to rewrite the content of a websocket message proxied through Nginx?
For example, say I've sent a message with the contents JSON.stringify({ auth: 'someIdKey' }). On Nginx, I would to substitute the value of someIdKey to someJwt, then forward it to the proxied upstream resource. I'd also want to do the reverse translation when the upstream resource sends out messages back to the client.
I know how to do this (and am doing this) for HTTP requests, rewriting custom headers to do an on-the-fly translation, but I'm not sure how to approach carrying over the pattern to websocket communication.
I'm using OpenResty as my Nginx distribution and am passably-ok at Lua scripting.
Would appreciate any ideas/help.