Upgrade header is key for applications needing to switch protocols without creating new connections—like WebSockets. By configuring your server and VergeCloud to properly handle upgrade requests, you can maintain high performance, ensure real-time communication works correctly, and avoid connectivity errors for your users. Remember to set precise page rules or edge configurations so that only the correct paths allow the Upgrade header to pass through.
The Upgrade header is an HTTP header that signals a request to switch to a different protocol on the same TCP connection. Although most common for upgrading from HTTP/1.1 to WebSocket, it can also be used for transitioning to other protocols (e.g., HTTP/2 or TLS-over-HTTP). This mechanism allows a client and server to maintain a persistent connection while changing the communication protocol on-the-fly.
Upgrade Header Works
When a client wants to switch from HTTP/1.1 to a different protocol, it adds an Upgrade header (and sometimes an Connection: Upgrade header) to its request. The server then evaluates whether it supports that protocol. If the server does accept, it returns a 101 Switching Protocols response, indicating a successful upgrade. If not, it either continues with the standard HTTP/1.1 communication or rejects the request.
GET /chat HTTP/1.1
Host: example.com
Connection: Upgrade
Upgrade: websocket
In this example, the client is requesting to upgrade from HTTP/1.1 to the WebSocket protocol.
Upgrade header is crucial for switching to WebSocket. If this header is blocked or removed, users may experience failures or disconnects in real-time features.
Upgrade header can introduce potential security risks if the server accepts protocol switches without proper validation. Ensuring your CDN and server only allow upgrades to supported protocols reduces the risk.
Upgrade header is generally used for protocols requiring persistent connections (like WebSockets), content associated with these requests is usually not cached. Additionally, some CDNs may require special rules or configurations to pass the Upgrade header through without stripping it or altering it.
Upgrade Headers in VergeCloudVergeCloud, like many other CDNs, uses a reverse proxy to accelerate your website. In some cases, you may need to instruct VergeCloud to ignore or allow the Upgrade header. This is especially important for WebSocket traffic or other protocol upgrades. If VergeCloud strips or modifies this header, WebSocket connections or other protocol transitions may fail.
Upgrade header on specific URLs or paths that require protocol switching.
/ws for WebSockets). Avoid allowing upgrades on every path to minimize potential security risks.
Upgrade header on endpoints relying on WebSockets or other protocols. This prevents unintended stripping or altering of headers.
curl or browser dev tools to ensure the Upgrade header is present and your WebSocket or protocol transition is successful.
101 Switching Protocols responses or upgrade failures. Early detection of misconfiguration saves time troubleshooting unexpected connection issues.