I've followed the instructions at https://wikitech.wikimedia.org/wiki/Help:Toolforge/Web#node.js_web_services and used the example server.js and package.json scripts provided there.
When I run a webservice shell and launch the script with npm start, I receive the error
throw new ERR_SOCKET_BAD_PORT(options.port); ^ RangeError [ERR_SOCKET_BAD_PORT]: Port should be > 0 and < 65536. Received NaN.
Clearly the javascript var port = parseInt(process.env.PORT, 10) ; is failing to identify the port.
This would presumably account for the "bad gateway" error reported by nginx when I run webservice nodejs start.