Is there a way to set the source port for a node js https request? I am not asking about the destination, not the source, that is, the port used to send the request.
In the context, I am trying to send https requests from a specific port, and not from random ports, which allows iptables to be blocked. node does not work as root, so the port is not 443.
Update: There seems to be a bug in Node. The localAddress and localPort parameters do not work, at least with a TLS socket.
Update: Found a similar question from last year. The answers were “don't do this,” which seems dumb, given that node is a common tool. Nodejs TCP Client Port Assignment
source
share