Portainer Agent Offline behind a reverse proxy: is 'websocket: bad handshake' a header-forwarding failure?
0 reputation · 21 Apr 2023, 23:57 UTC
0 reputation · 21 Apr 2023, 23:57 UTC
Consider a Portainer CE 2.19.x deployment where the Server and Agent run on separate hosts. Connecting from the Server host directly to the Agent port reports the Agent as Online, but in production — where traffic passes through a reverse proxy — the environment list shows the Agent as Offline, and the Server logs record a WebSocket handshake failure ('websocket: bad handshake', as noted in Portainer's troubleshooting documentation).
The suspicion is that the proxy does not forward the HTTP Upgrade and Connection headers required for the Server–Agent tunnel, so the handshake is rejected before TLS validation plays any role. The open uncertainty is the production path itself: it may include more than one hop, for example an NGINX front end in front of a cloud load balancer, and it is unclear whether every hop must preserve those headers.
The goal is for the Agent to report Online through the production proxy path, without bypassing the proxy.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.