I'm designing an application that make will use of WebSocket to notify visitors quickly when changes occur. I'm planning to proxy the connections with Nginx, so they can share the same address as the regular HTTP portion. One thing I'm concerned about is the exhaustion of ephemeral ports. In the past, I have noticed problems when the number of connections between Nginx and the Node backend exceeds 25000. My question is, would the following config increases the limit to 100K?
upstream backends {
server 127.0.0.1:5000;
server 127.0.0.2:5000;
server 127.0.0.3:5000;
server 127.0.0.4:5000;
}
The limit on open files will need to be raised accordingly, of course.
Assuming the technique works, can it be used with external servers? How hard is it to assign a range of IP addresses to an interface? Networking is not my forte...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With