Often, you may want to forward ports on your system for tasks like playing multiplayer games. Or, while developing web applications, you may come across situations when you want to forward ports on a system, so that your system can work as a server. Some of the ports are used by specific applications (like the well known port 80 that expects to listen from a Web Client), while many others are free for the developers to use in their application. You can use ports like 4444, 1604 etc.
How to forward ports?
=>First of all, install nginx. It is a free, open-source HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server, that makes port forwarding as easy as 1-2-3. To install it, type:
sudo apt-get install nginx-full
=>Find the ip address of your machine by typing
ifconfig
inside the terminal. In our case, it is 192.168.1.8

=>Type the following command to open the sites-enables file in a text editor:
sudo gedit /etc/nginx/sites-enabled/default
=>After the server{ tag, there are a couple of lines similar to the following:
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
Replace them with:
listen 192.168.1.8:4444 default_server;
Replace 192.168.1.8 with your own computer's IP address and 4444 with the port that you want to open.
=>Save the file and close it. Now,type:
sudo nginx -t
Now you have to restart the nginx service by typing:
sudo killall nginx
Then, type:
sudo nginx
And it's done! You can confirm that the port is opened by using nmap. If nmap is installed on your system, type:
nmap -p 4444 192.168.1.8

If you do not have nmap installed, you can go to http://www.yougetsignal.com/tools/open-ports/. Inside the Port Number box, type the port that you want to test(4444 here) and click on Check button.

That's it! As you can see, it is pretty straightforward to open ports into your system using nginx. If you find it useful, please let us know in the comments section... :)
No comments:
Post a Comment