Proxying WebSocket connections and ephemeral port exhaustion
Please try proxy_bind . It
Makes outgoing connections to a proxied server originate from the specified local IP address. Parameter value can contain variables (1.3.12).
So if our nginx proxy server can have several IP addresses your problem can be resolved. e.g.
location / { ... proxy_bind $picked_ip; proxy_pass http://backends;}
The variable $picked_ip
can be computed by a rewrite handler which runs before proxy_pass
does.