make a localhost port accessible over internet - NodeJS - node.js

I'm asking this question specific to nodeJS , but maybe it applies to other web development frameworks as well.
I have a nodeJS Express hello world application running on my laptop listening to port 3000(I'm using Linux Mint Sylvia 18.3).The localhost:3000 and < localIP >:3000 requests to access this app works fine from the same machine and also within the local network of my Router. But when I do a port forwarding on my router to port 3000, and try to access this app via < publicIP >: 3000, it doesn't work.
This is not for any production purposes, but just for learning. How do i make my hello world app accessible over the internet without the help of any 3rd party web server applications (apache/nginx etc) or any local tunnelling (like ngrok)- i.e just like how we access a HelloWorld app from AWS EC2 server by accessing the server < instance >:< port >.

You can make your Node JS or any other application on any port public temporarily by using
Localtunnel
ngrok

Related

Best practice for Deploy Node Express application and php application on AWS ec2 instance

I have an AWS ec2 instance along with one domain. I want to deploy my express node application and PHP application on the same server without adding a port with the domain.
For PHP deployment I have configured xampp server with a default port of 80.
And my node application runs on port 3000.
Currently, I am accessing the node app using - mydomain.com:3000
and for the PHP - mydomain.com/website
I wanted to use an express node app without entering the port number. example - mydomain.com
Is there any way to configure it with my given scenario?
Perhaps what you want is to run two different applications on one physical server.
How about approaching the concept of load balancing on one server?
Typically, you can implement this using nginx's reverse proxy and upstream.
For example, if the node server is running on port 3000 and the php server is running on port 4000
In nginx node.mydomain.com is port 3000
php.mydomain.com can send on port 4000.

Deploy Create-React-App on a remote Windows Server

I am an inexperienced intern working with a remote Windows Server and React. The Windows Server is running in the company network. I have created a dynamic React website with a NodeJs backend and React Router. I have only ran it on the localhost development server. I want to try to deploy it on the remote Windows Server and give it a custom domain name (Something which can be accessed like servername/myreactapp/).
So far, I have had no success trying to make it work with IIS, even with a web.config file (I get 404 and 500 errors). I am currently making it work by actually running the development server and the nodejs server in the Windows Server, and I access it through the server IP at port 3000.
An improvement would be to be able to access the port through the server name (like servername:3000, instead of the server_ip:3000), but ideally I want to be able to access it like servername/myreactapp/.
Any help would be appreciated. Thank you very much.
The simple solution would be to run your app on port 80 then you will not have to specify the port number.
The best solution would be to set up Nginx on the server and proxy_pass / route to port 3000.
If its running on localhost, which would be port 80, the url would be like http://your_server_name:80, and would be accessible by anyone on the same network, as long as your authentication allows it.

Node app listen on port lower than 1024 on Google Cloud App Engine

I have created an app engine which runs a node application that serves some html, css, and javascript.
I want my node application listen port 443. However my node application gives 503 error if i run it on a port other than 8080
I searched in the web and think that there is a service which accepts clients' requests on port 80(I dont know where the service is running). This service redirects these requests to 8080 port of a virtual machine. And this is the virtual machine that runs my node application.
Please correct me if i am wrong.
So how can i change the configuration of that service to redirect incoming requests to my application on port 443?
Your application must handle requests via port 8080. If you're trying to use port 443, I'm guessing you're trying to serve SSL. You can find out more about how to do that in App Engine Flexible (where your Node.js is running) here and here.

Allowing external access to node.js application while hosting through XAMPP

So I have the following URL that leads external users to my port-forwarded XAMPP website.
http://ip_to_my_computer:433
However, my node server is on port 466. How do I connect to it? I can't do
var client = io.connect('http://ip_to_my_computer:433:466');
Thanks!
It looks to me like you're trying to initiate a client request from your XAMPP hosted server (like a .php or .js script) to your Node.js instance?
Simply:
var client = io.connect('http://ip_to_my_computer:node_server_port');
And in your case, you claim your Node server is running on port 466.
I'd bet though that your OS will block a port that low - try changing your Node server to listen on a port between 8000 - 9000.

Socket.io on port 80

I've made a node application which listens on port 80, my application works fine on localhost, but when I run it on my VPS, I get a different log and a different result ( websockets just don't work )
A comparison between localhost's log and VPS' log:
Node's log on localhost
Node's log on VPS
As you see, in VPS, xhr is used instead of websocket after it says "info: transport end (socket end)"
I don't use any web server on my VPS and I ran my application as root.
Are you running a web server in front of your node app on your VPS? If so, make sure it is new enough and properly configured to do websockets. For instance, on modern Ubuntu the stock nginx is not new enough yet to support web sockets, so you have to install a separate package to get websocket support.
2nd guess: is there a proxy server between your browser and your VPS?
Have you run it as the super user on the VPS? Normal users are typically blocked from opening ports below 1024.
Our server hosted on VPS, using port 80. The io connection fired through cellular data and through WIFI fine, but in some wifi networks it didn't.
So we had used different port, then it works.

Resources