New Three new products: fordway trading ERP, UEPS cloud rendering and WPECS delivery and operations View products →

Why the Pixel Streaming video disappears behind another reverse proxy

Engineering By SREYUN 0 views

Many companies already have a reverse proxy at their edge: the router's built-in proxy, 1Panel / OpenResty, Nginx Proxy Manager, a cloud load balancer or a CDN. It holds the real certificate and forwards https://ue.example.com:8443 to the Pixel Streaming gateway inside. When deploying UEPS behind such a setup, the most common symptom is: the page loads, signaling works, and there is never any video.

Where it breaks

A front proxy handles pages and signaling fine as long as it supports WebSocket (forwarding the Upgrade and Connection headers), keeps the original Host header including the port, forwards X-Forwarded-For, and allows read timeouts of at least 60 seconds (signaling sends a heartbeat every 30 seconds).

Video, however, travels over TURN. The browser builds TURN addresses from the page URL and connects to port 8443 on the front proxy, which treats the connection as an ordinary HTTPS request and answers 400 Bad Request. A plain HTTP proxy cannot forward TURN; that is a protocol limitation, not a configuration mistake.

Option A (recommended): a layer-4 split on the front proxy

If the front proxy is nginx or OpenResty, its public port can be received by stream { ssl_preread on; }, which splits traffic at layer 4 before deciding where it goes:

  • TLS with ALPN for this domain (pages and wss): goes to the https reverse proxy as before;
  • TLS without ALPN for this domain (the browser's TURNS): the front proxy terminates TLS with the real certificate and hands plain TURN to the gateway;
  • Plain connections: stay on the front proxy (redirect to https);
  • Other domains: unchanged.

The certificate stays on the front proxy, and neither the gateway nor UEPS needs any TURN changes: the default turns:{host}:{port} works as is. The project ships an example in deploy/nginx/front-proxy.example.conf; the front proxy must reach the gateway over http://gateway:port, keep the Host header and send X-Forwarded-Proto: https and X-Forwarded-For.

Option B: one extra plain TCP forwarding port

If the edge device can only do HTTP proxying, open one extra plain TCP port forward on the router (layer-4 forwarding, not a reverse proxy), for example external TCP 8444 to gateway 443, and add an entry under System settings, Playback path, TURN servers:

turn:{host}:8444?transport=tcp      shared secret @builtin, scope: viewers only

Browsers try several TURN addresses at once and use whichever works. Pages and signaling keep going through the front proxy, and media uses the new TCP port.

What testing showed

The project reproduced this topology in a test environment: port 8443 on a public domain went through the router to an internal OpenResty, which proxied to the UEPS gateway.

  • Pages and signaling worked; TURN to 8443 got a 400 from OpenResty, and there was no video.
  • Adding a TCP 8444 forward on the router and turn:{host}:8444 on the platform brought playback back (option B).
  • With a layer-4 split on a front nginx generated from the example, all 5 split self-checks passed (wss signaling hands out turns:, TURNS reaches the gateway's TURN, plain traffic is not passed through, http redirects, other domains are unaffected), and three consecutive browser sessions ran over relay/tls at 27 to 28 fps with zero packet loss (option A).

Do not forget the viewer's real IP

Behind a front proxy, every connection reaches the gateway from the proxy's internal address. Left alone, "one session per IP", "per-IP limits", rate limits and the internal / external decision all go wrong: every remote viewer looks like the same person, or like a LAN viewer.

Enter the address the front proxy uses to reach the gateway under System settings, Network and access control, Trusted reverse proxies (or UPSTREAM_PROXIES for docker-compose). Only list real proxies: the platform reads X-Forwarded-For from right to left and takes the first untrusted address as the viewer's IP, so a forged X-Forwarded-For header from a client has no effect. Loopback addresses are always treated as trusted proxies.

Occasional 502 errors

Sporadic 502s between a front proxy and the gateway usually mean nginx's upstream keepalive timeout is longer than the platform's idle timeout: the platform has already closed the connection while nginx is still reusing it. UEPS's deployment files set nginx to 60 seconds and the platform to 65, so nginx always closes first.

Checklist

  1. The front proxy supports WebSocket, keeps Host including the port, forwards X-Forwarded-For and has read timeouts of at least 60 seconds;
  2. TURN uses a layer-4 split (option A) or its own TCP forwarding port (option B), never a plain HTTP proxy;
  3. the front proxy's address is listed as a trusted reverse proxy;
  4. on a computer outside the network, open the player, click Status and confirm the path is a TURN relay over tcp or tls.

For more network scenarios, see "Why Pixel Streaming goes black on the public internet" and the UEPS product page.

Related articles