Using reverse proxy with TTMSFNCWebSocketServer and TWebSocketClient

I am trying to use a reverse proxy with TTMSFNCWebSocketServer in a delphi service. I cannot get it too successfully handshake when using the reverse proxy. If I connect directly from the browser, it works fine. I am using a wss connection. I tried a couple of different proxy software but all get the same 502 error. Has anyone successfully been able to do this? Suggestions would be appreciated.

Hi,

Unfortunately we don't have experience with putting a reverse proxy in between, but based on a quick research it looks like the proxy itself should create it's own websocket connection with the client and the server separately and forward the incoming messages from the client to the server.

Is it the proxy server that gets the 502 error from TTMSFNCWebSocketServer or is it the TWebSocketClient that gets the error from the proxy server?

If it's the proxy server getting the error, I think you might need to check what is going on with HTTP and HTTPS connection. SSL will be terminated coming from the clients to the proxy also needs an SSL certificate.

If it's the TWebSocketClient getting the error, it means it cannot connect to the proxy websocket server, you'll need check how to enable and set up for the service you are using.

Thanks for the response. It seems the proxies that I have tried all modify (add / change) the HTTP header on the inbound connection to the backend and the outbound back to the browser so the initial handshake fails. I have tried extensively in IIS and Caddy. I have tried various methods to preserve the headers but that does not seem to work either. The header never matches exactly which causes it to fail. I employed both ChatGTP and Copilot to help with the configuration but the handshake always fails on the browser side. I was hoping that someone may have figured out. I want both the web pages and web sockets to use port 443 with encryption. I guess my next option is a cloud VM with multiple internet facing IP addresses.