Set up a dedicated Node.js ubuntu server that can be accessed by external network

I am working at the TAMK campus network, so it is not easy to set up a  dedicated Node.js ubuntu server that can be accessed by external network both on virtual machine or actual network for previlidge and permission.

At last I choose to use my laptop to install dual windows 7 and ubuntu system and set up a dual boot system. Then set up the node.js ubuntu server.

Problem comes out again. How to transfer the design files made on PC to the laptop server and then access the server though PC and my phone which use the same wifi network with the laptop.

It takes a couple of hours for me to solve this problem, now, both PC and phone can access the server on laptop. But design files can not be transfered from PC to server I afraid.

This is my solution:

1 install a nodejs server listening to port 8080

My server code

var http=require('http');
response.end('Im Node.js.!\n');
console.log('Handled request');
}).listen(8080, "");;
console.log('This is a http running on NODEJS');

server ip is 192.168.x.233

Set the listener to make the internal(LAN) network within the same intranet sharing the same router access the server.

So on the phone which is using the wifi network with laptop can easily access the node.js server by input:192.168.x.233:8080

First, be sure that nodejs is actually listening to such port:

sudo  netstat -tpln

Let’s check iptable:

sudo iptables -nvL

Notice the line in your netstat output …

tcp        0      0*               LISTEN      18843/nodejs 

Specifically the local address of That means that nodejs is only listening on the localhost address and so only will accept connections from the same machine.

From reference:

The following command can open the port 8080:

following command:

iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT

For me, there is no such issue.

Then I try to access the server from the PC whose ip is 192.168.112.x

I suppose to think that TAMK wifi router and LAN router should be in the same intranet, so I try many ways to solve this.

I try to modify httpd.conf

But it seems that there is no such file which is running apache server.

Added inbound Rules.

And I Add a line at the very end of your hosts file  located in /etc/hosts similar to this :


The IP address (in the example above it is 192.168.x.88) is the address of your localhost; Your computers IP address. The domain name ( is what is mapped to the IP address.

After you save that file, whenever that computer points to, it will be directed to your IP address. Firewalls are still a barrier – however the other answers covered that so I will not repeat their contribution.

The above method do not solve the problem.

At last I think of the solution:

I try to find the IP on the

And the one on laptop is :193.167.x1.x2


Then I think that these two networks are totally different. So I consider to solve the issue by virtual Hosts.

According the mentioned artical, ngrok can provide this service. So I download one to the ubuntu system and then unzip under GUI. and run

./ngrok http 8080

You’ll see a screen like so:

ngrok running on port 80

Note: mine is different

In the example above, we’ve got traffic to a randomly generated ngrok address of being forwarded to our localhost on

Open that URL on any device with an internet connection and you’ll be accessing your localhost from the web!

Then I can assess the url from my browser of my PC!

I guess there is only http severice that ngrok can provide for free, so it is impossible to share the files with PCs and laptop with ngrok without payment. But that’s enough. I can share file by other means like connect laptop with LAN cable to let the two systems run under same intranet. Of course, this way can save a lot of time if do this in the beginning. But the solutions and the process above obviously let me know more about the network knowledge!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s