Many of us wished to have a personal web server right at our home. Why rely on other web hosting services to manage you network when you can do that for yourself? This article is an attempt to help to setup a simple web server infrastructure at home. It intends to give users an insight into what it takes to setup a web server (for matter of fact any server) and put it online?
You will need following things to get started:
1. High speed broad band connection
To setup a web server, you need to have a stable broad band connection. The down time should be minimal, so that our web server will have a maximum presence on the web. Also you should have at least 1 MBps bandwidth to cater for 10-100 hits per day. We can setup the web server with low bandwidth also, but access time will become slower as concurrent users increases.
2. Server
We do not need any expensive servers to host our own website. For your surprise, web server can be hosted on any PC grade machine as long as it has a decent processor and enough RAM. I will recommend Intel/AMD processor having speed in excess of 1GHz and at least 1 GB RAM. Large hard drive is required if you are planning to host Gigabytes of data.
3. Web server software
You will be likely to use either Microsoft Windows or Linux operating system on your web server. Both are good and robust operating systems for hosting a web server, provided proper OS configurations are in place. I will highly recommend Apache web server software. If you are hosting web sites on windows then download Apache server from http://www.wampserver.com/en/download.php. This is a packaged solution, containing Apache, MySQL and PHP for Windows. If you are using Linux, it is most likely that Apache web server is installed by default, or else please install it from your Linux distribution CD/DVD. (Installation and Configuration of Apache web server is out of scope for this article. Please refer Apache home page http://httpd.apache.org/)
If you want to host a minimalistic web server then have a look at http://code.google.com/p/mongoose/
With the above components in place we are ready to build a home we web server.
Here I am assuming that you have an ADSL broadband Internet connection. Your Internet Service Provider might have provided you an ADSL router that connects your home network to Internet.
Nowadays most of people have more than one computer at home. So it is likely that you have a WiFi router installed and it is connected to ADLS router for Internet sharing. A typical home network infrastructure is as shown below:
(Please click the image to enlarge)
Network Topology
ADSL router is equipment that connects your home network (private network) to internet (public network). Hence ADSL router will have basically 2 IP addresses, in the above scenario they are 59.184.32.12 and 192.168.1.1. Your IP addresses will be different depending on the router configuration. Just replace above addresses with your actual IP addresses for better understanding of network connectivity. The IP address 59.184.32.12 (WAN address) is assigned by ISP every time ADSL router gets connected. (To know your WAN IP address visit http://www.whatismyip.com/) In general this IP address will vary every time you connect, hence it is dynamic in nature. It is must, to have this IP address constant, every time you connect to internet otherwise users will not be able to access your web server because of changing IP address. Please purchase a static IP address from your ISP for a minimal monthly or yearly fee.
The address 192.168.1.1 is the LAN address for the router and it is not exposed to public network. The WiFi router connected to ADSL modem has an address 192.168.1.3. Now important point to note here is, our WiFi Router will also have 2 network addresses as shown in figure since it bridges 2 networks. To make the picture clear we have in total 3 networks as shown below:
Network 1 = Internet (public network)
Network 2 = 192.168.1.1, 192.168.1.3 (private network)
Network 3 = 192.168.0.1, 192.168.0.100, 192.168.0.101 (private network)
Please note that the first 3 numbers of IP address in a network must be identical. (The first 3 numbers constitutes network id and is unique for a network)
You can assign these IP addresses (except WAN IP address ofcourse!) manually or using DHCP server available on ADSL modem and WiFi router. But make sure network id is same for all the computer in a given network.
You can assign these IP addresses (except WAN IP address ofcourse!) manually or using DHCP server available on ADSL modem and WiFi router. But make sure network id is same for all the computer in a given network.
Hosting web server
Please make sure we have a proper network topology as explained in previous section to move ahead with web hosting.
Now let’s host our web site in one of the server on our private LAN. The IP address of our web server is 192.168.0.100. Since it is a private LAN address it will not be accessible from Internet.
Install your choice of web server on 192.168.0.100 and test it locally by typing http://192.168.0.100 in web browser. The home page must be seen with no error. If the home page is not visible please check you web server configuration. Check whether web server is listening on port 80. This can be easily configured in httpd.conf for Apache web server.
Exposing web server to Internet
Once you have the web server installed successfully, it will only be accessible from private network but not from outside. The goal is, to access the web server from outside by entering http://59.184.32.12
If you try to access that page from internet it will return failure. (Please use your friend’s internet connection to test your web server. If you type http://59.184.32.12 from your own home network you will end up accessing ADSL router configuration page not the actual web server)
The problem here is that our ADSL router doesn’t know to which machine (in private network) to route the request for http://59.184.32.12. The key to solve this problem is, to let the router know where to forward the HTTP request. This is configured with Port Forwarding setting in ADSL modem and WiFi router.
Open up your ADSL modem configuration page, most probably at http://192.168.1.1 and in port forwarding screen enter following values:
Local Address From: 192.168.1.3 (Note: Enter your WiFi router address here. Refer Topology diagram)
Local Address To: 192.168.1.3 (Note: Enter your WiFi router address here. Refer Topology diagram)
Global Address From: 0.0.0.0
Global Address To: 0.0.0.0
Destination Port From: 80
Destination Port To: 80
Local Port: 80
(Please note the configuration screen will be different for different ADSL modem. Refer http://portforward.com/ for exact details)
Open up your ADSL modem configuration page, most probably at http://192.168.0.1 and in port forwarding screen enter following values:
Local Address From: 192.168.0.100 (Note: Enter your web server address here)
Local Address To: 192.168.0.100 (Note: Enter your web server address here. Refer Topology diagram)
Global Address From: 0.0.0.0
Global Address To: 0.0.0.0
Destination Port From: 80
Destination Port To: 80
Local Port: 80
Commit the changes and reboot both ADSL modem and WiFi router for the changes to be effective. You can test port forwarding at http://www.yougetsignal.com/tools/open-ports/
When a request for http://59.184.32.12 comes, the ADSL modem forward that request to our WiFi modem at http://192.168.1.3. Now WiFi modem in turn forward that request to http://192.168.0.100. This kind of IP address translation is called as NAT (Network Address Translation). Since we have two routers in place we need to do double NAT. Should your web server be directly connected to ADSL modem we would have required only single NAT.
NAT is hardest part in setting up web server at home that requires some understanding of network topology.
Firewall Settings
It is highly recommended that you should enable firewall at every place in private network. ADSL modem, WiFi router and web server will have some kind of firewall installed on them. Now to let our HTTP traffic passes through these firewall, you need to open HTTP port 80 at all the firewalls. (Setting the firewall is out of scope for this article as it varies for different router manufactures and operating system)
Once the above settings are done, you should be able to access the web server hosted on private LAN by typing http://59.184.32.12 (Please access this address from other internet connection)
Domain Name
Accessing your site with something like http://59.184.32.12 is not user friendly. You can get yourself an attractive hostname like http://coolwebserver.com from domain name registration services like http://www.hostgator.com/domains/
Hosting FTP server
Suppose you want to host your own FTP server at another local machine, let say 192.168.0.101. This can be easily done by adding one more port forwarding rule, at ADSL modem and WiFi router, as explained above. The only change is the Local IP address, in this case it is 192.168.0.101 and port number as 21 keeping everything else same. Now you will be able to access your FTP server at ftp://59.184.32.12.
Similarly you can host other services like Telnet, SSH, SMTP on your private network.
Downsides
This is all about the setting up basic web server at your homes. There are few points that you need to understand about web hosting.
With this knowledge you can be your own webmaster for your very own site!
This is all about the setting up basic web server at your homes. There are few points that you need to understand about web hosting.
- First of all this is not a replacement for a good web hosting services. A good web hosting services will have a robust infrastructure with high bandwidth connectivity to internet, backup servers, backup power supplies, dedicated technical support team for fault rectification and periodic backup of web sites. All this cost money and all these services are charging for the same.
- This setup is good for hobbyist and geeks to experiment with high bandwidth Internet connection but not suitable for enterprise for above said reasons.
- Normally security is issue with home server and hence they can be easily exploited to gain un-authorised access.
- ADSL has low upload bandwidth than the download bandwidth, this may put some restriction of rich media sites. So if you are planning to host youtube.com kind of service then it is not the right choice.
With this knowledge you can be your own webmaster for your very own site!
(This article is basically intended for average to expert user. But beginner will not find much difficulty in understanding the concepts and implement them)

0 comments:
Post a Comment