What else is required to access a node app from outside a Digital Ocean droplet? - node.js

We have set up a node server which runs on port 5000.
In a newly created droplet, we have installed and started nginx. To access the node app, we have changed the default port from 80 to 5000 in /etc/nginx/sites-enabled/default
server {
listen 5000 default_server;
listen [::]:5000 default_server;
ufw is enabled
sudo ufw enable
Also the port is enabled
sudo ufw allow 5000/tcp
Also, tried this way too:
sudo ufw allow 5000
As confirmed with sudo ufw status
netstat -ntlp
Also the app is configured to listen on the public interface
const server = app.listen(process.env.PORT || 5000, '0.0.0.0', () => {
console.log('Express server listening on port %d in %s mode', server.address().port, app.settings.env);
});
However, not even the default port was responding. Hence, we reverted to 80 as the default port.
What else is required to access node app outside of the droplet?

When it comes to NodeJS and NGINX, we'll want to configure NGINX to listen on port 80, though we'll want to use proxy_pass to pass the request from the web server (NGINX) to the NodeJS application on the port that the application is running on. This will allow us to keep the port out of the URL.
With the current configuration, NGINX would be listening on port 5000 which would prevent the application from being able to listen in on the same port (or vice versa).
There is an excellent guide that covers setting up NodeJS + NGINX -- this specific part is the most important:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server
The above covers how we'd go about setting up the Server Block :-)

Related

HAProxy configuration ports issue

Hi :) I have problem with HAProxy configuration. I have haproxy and two backend servers (backend servers listen on 1234 port)
It's my haproxu config:
frontend http_front
bind *:80
backend http_back
balance roundrobin
server server1 10.0.0.2:1234
server server2 10.0.0.3:1234
This config doesn't work, but when i add to frontend:
bind *:1234
It works great - i don't understand it because bind *:1234 inform only haproxy to listen on 1234 port nothing more. Have you any advices or explanations ?
Port 80 is a privileged port, this means that you can only start haproxy as root when you want that haproxy should listen on port 80.
Another reason could be that there is another server listen on port 80. Maybe a web server run also on this machine which listens on port 80.

Trouble conecting to Node Server on EC2 Instance

I have a Node application running on an EC2 instance, and after npm start, I am unable to connect to the application via the web, but everything indicates that it is running correctly.
Here's how my server.js looks like:
app.listen(8000,"0.0.0.0", () => {
console.log("app running on port 8000");
});
How are the inbound rules of the EC2 security group:
I saw on other sites that removing " 0.0.0.0. " From app.listen and leaving only the port would solve the problem, but unfortunately that didn't work.
Another thing I tried was to add a * Custom TCP * rule to port 8000 in the security group, but this prevented the application from running, saying that the port was already in use
Something is already listening on port 8000, a netstat should tell you what it is.
Simply add a TCP security group for port 8001 or 8080 and in your code use that port instead.

I can't listen express server on port 80

I'm trying to create an express server using node.js but when I start the server on port 80 my friends can't use it. I can select any other port and it will work, but when I try port 80 it doesn't work. I'm using https://www.yougetsignal.com/tools/open-ports/ and https://portchecker.co/check to check if the port is openned, I tried with 3000 and it work perfectly, but I need to get it working in port 80. I have already disabled my firewall and setup my DMZ host in the router.
I believe you are using windows as OS. In it the port 80 could be used as default port for some service. Please check the following -
Skype uses port 80 by default, you can change this in skype options > advanced > connection - and uncheck "use port 80"
Port 80 is the standard HTTP port, so to check which services are using you could run net stop http. It will list the services using port 80 and will ask to whether end them or not.
Port 80 could be occupied by IIS server. Please stop IIS and then re-run the node service.
Some SQL Server Reporting services also use port 80

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
},

how to allow access to port on AWS

I am trying to connect to my development port port 3000 on aws but it is not working. I have currently configured my domain with the instance and it is working fine but I cannot access port 3000 and get ERR_EMPTY_RESPONSE
The security group setting is as below
As you can see, I have opened up my mongo port 27017 and 3000 which is my node server port
As you can see here, it is listening at port 3000. I set it to print out the exact port that is being listened.
When I go netstat -natlp the following shows
port 3000 is currently listening.
I have followed all the instructions and suggestions but it is still not working for a weird reason. The server I use is Asia(Seoul) server.
Am I missing something here?

Resources