Story-Time (Basically non-sense): Ever since I got Apache2 installed on my computer, I was thinking – if I can view the sites I build using Apache/Tomcat on my computer, why can’t I view them from another network. The concept is the same – files put in web server, web server hosts the files, we use the web browser to view the files. So why can’t I just ask my friend to punch in my IP and get him to view my files/site. The problem – the IP we are using is dynamic most of the time, meaning it’s going to change constantly, second – the port ain’t forwarded. So what do we do?
Actual Stuff / The How-to:
Note : The following how-to is specific to Beetel 220BXI modems but the idea is pretty much the same even with other modems. Also I am using Ubuntu 10.04 (Lucid Lynx) as my Operating System
Things we will need:
- A web server like Apache or Tomcat
- An account with a DNS hosting service like dyndns.com
What to do :
Step 1: Register for an account with the DNS hosting service of your choice like http://www.dyndns.com/
Step 2: I use a Beetel 220BXI modem. So the modem’s configuration can be done by punching in 192.168.1.1 in my web-browser. Put it the Username and Password for your modem, if you have never changed the password then you should be able to find the default passwords for modems at http://portforward.com/
Step 3: You will see the modem’s web-page, something like this,
Step 4: Navigate to Advanced Setup->DNS->Dynamic DNS. In the Hostname field, put in your IP that you signed up for at dyndns.com or something similar and in the Username & Password put in the DynDNS username and password
Step 5: Now, navigate to Advanced Setup-> NAT -> Virtual Servers. Click on the “Add” button. Now choose WEB from the service list, and modify the External Port and Internal Port to read something different like 8090 and the internal server IP address field should have the address of the local web server, usually, 192.168.1.2 (Check before making the entry) and click Apply
Step 6: Now, navigate to Management->Access Control -> Services . Tick the box under the WAN column that says HTTP
(You can choose to install either one of the servers. If you prefer Apache2, follow steps 7-9 and if you prefer Tomcat6, follow steps 10-12)
Apache 2 Instructions (Steps 7 – 9):
You can install Apache2 easily by either of the following commands:
sudo apt-get install apache2
sudo apt-get tasksel && sudo tasksel install lamp-server (this installs Apache2, MySQL and PHP)
Step 7: Time to change the Listening Ports on Apache Web Server. If you have everything in the default state the following steps should work just fine. Enter the following in a terminal gksudo gedit /etc/apache2/ports.conf and it should open up a file, there replace the default Ports to 8090 or some other port (Make sure the listening port mentioned here is same as the one mentioned before in the modem configuration)
Step 8: Now as hinted in the ports.conf file, we need to also change another file, so type the following in your terminal gksudo gedit /etc/apache2/sites-enabled/000-default and edit the ports as in the previous step to 8090 or the port of your convenience
Step 9: After the configurations done to Apache2, we have to restart the service inorder for the change to take effect. That is done by the following command
sudo /etc/init.d/apache2 restart
And, that’s it. You should be able to see the default page when you visit http://your-dyndns-address:8090 from another network. (If you checked the ICMP box in Step 6 it’ll prompt for the router’s username and password, but after that you should be able to see the default page) You can put your site inside /var/www folder (just incase you are new to all this and didn’t already know that, that’s where the webserver hosts the files from)
Tomcat6 Instructions (Steps 10 – 12):
You can install Tomcat6 by this command:
sudo apt-get install tomcat6
Step 10: Type this in the terminal to open up the configuration file for Tomcat6 which is at /etc/tomcat6/server.xml
gksudo gedit /etc/tomcat6/server.xml
Step 11: Search for text that looks something like this:
<Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
URIEncoding=”UTF-8″
redirectPort=”8443″ />
Now replace the port number with the one that you forwarded your external port to. In our example, it’s port number 8090
Step 12: Place your website in the folder /var/lib/tomcat6/webapps/ROOT/
And that’s it, ta-da, you have your own personal web server accessible from anywhere. Enjoy.
Nits
Note: The reason why we forward port external port 8090 (Step 5) is because in some cases the ISP may block port 80 so as to not allow home users to host stuff. Try forwarding port 80 just in case, if not, 8090 should be just fine
References:
http://blog.prashanthellina.com/2007/12/10/accessing-your-home-computer-from-the-internet/






Hello
my Advanced Setup->DNS->Dynamic DNS page does not exist
a firmware suggestion?
Just look around in your settings, else-wise you could also head down to http://portforward.com/english/routers/port_forwarding/routerindex.htm and search for your specific router there. Hope that helps.
very nice post, i actually love this website, carry on it
Thanks
Comments like yours encourage us