node-RED port number - node.js

Can we set port number of node-RED is same with another port number?
ex: test.js is running on 1880 port number, and then node-RED port number is 1880 too. but httpRoot will be actived,so when I run the node-RED, I use 127.0.0.1:1880/red. Is it possible?
Thank you

No, two applications can not share a port like this directly.
You could use something like nginx running on port 1880 and run test.js and Node-RED on different ports and have nginx proxy requests to the separate applications.
Or you could look at the documentation for embedding Node-RED and include Node-RED into your test.js application.

Actually Im pretty sure you can, if you are listening on different interfaces.
So for example if you listen on eth0 port 80 for incoming requests to a program you could listen on port 80 on localhost (or eth2) for another program.
So if you can constrain the socket of both applications to listen on a specific (different) interface it will be ok.

No. You cannot use that port for Node-RED if its already being used. Run Node-RED using the following command:
node-red -p 1881
This will start Node-RED on a new port (1881), so whenever you want to use a new port, use this command as you can start multiple Node-RED services.

Related

Running NodeJs application on port 80 of amazon linux

I am trying to get a NodeJs application to run on a Amazon Linux server using port 80. Currently when I run the app it is defaulting to port 1024. I understand that this is due to the fact that I have to be root to run on port 80 but given I am on a aws linux box I am not able to run that as root. I have been digging for awhile but I am coming up short on what I need to adjust to get this to run properly.
sudo bash will allow you to connect as root on your EC2 Amazon Linux instance.
I would question why do you want to run NodeJS on port 80, the best practice would have a load balancer in front of your instance to accept HTTPS calls and relay to whatever port nodejs will run on your instance, in a private subnet.
I would suggest to read this doc to learn how to do this : https://aws.amazon.com/getting-started/projects/deploy-nodejs-web-app/

How to change "mediasoup" port

I installed mediasoup and ran it as well!
But it's working on 3000 port.
I couldn't find listen port in its sources, How i can change this port to443?
Actually you did not install mediasoup but the mediasoup-demo which, indeed, includes a WebSocket based signaling protocol that listens in port 3000.
mediasoup-demo it's just a demo, not an application or product.
If you need to listen bellow than 1024 port then you need to run as administrator on windows and as a root(sudo) user on Linux/MAC that is sudo node server.js
and as documentation of https://github.com/versatica/mediasoup-demo, you must update port on config.js
protoo :
{
listenIp : '0.0.0.0',
listenPort : 443
},

Heroku running a node module server

I am trying to create a node app that runs a module called noodlejs. This starts its own server running on port 8888 (on my local version). I have pushed the changes to heroku and no errors are caused. However how do I now access the noodlejs server on port 8888? Is this possible or does it need to run on another port?
Thanks!
I don't think you can run the app on port 8888 or any other port for that matter on Heroku. You can only choose between 80 or 443. And to do that, you use process.env.PORT environment variable that Heroku exposes.

How to redirect port 80 port 900 Node Server using apache2

I have a node app running on port 9000 with forever on Ubuntu 14.04. I can simply run my app on port 80. But it needs root privileges. And I found that It's not a good idea run a server software on port 80 with root privileges. So the alternative is reverse proxy. To be honest I know nothing about reverse proxy or the way to do it. So can anyone guide to through it ?
simply what i want to do is run my node app on port 9000 and make sure it's available on port 80 using apache2.

webserver node.js as non root user

I'm a Linux beginner and have a Linux Ubuntu 12.04 server. I've installed node.js and created a webserver script. That works fine, but it runs as root user.
I know that's not good (root-user & webserver = unsafe).
How can I run the webserver script as an non-root user? Does somebody know a good detailed tutorial or can give me some advice?
You have two options:
Listen on port 80
Run as root, start your app's listen() on port 80 and them immediately drop to non-root. This is what Apache does, for example. Not recommended since it's easy to get this wrong, and lots of other details (writing to log files, initialization required before you can listen, etc.). Not standard practice in node.
Listen on port >=1024*
Run as non-root, listen on a port >= 1024 (say: 8000, or 8080), and have someone else listen on port 80 and relay port 80 traffic to you. That someone else can be:
A load-balancer, NAT, proxy, etc. (Maybe an EC2 load balancer if you're running on EC2, e.g.)
Another http server, say Apache httpd or ngnix.
For an ngnix example, see this: Node.js + Nginx - What now?
you can just run node hello.js

Resources