I have a local area network in my home office with some Windows and one Linux computers on it.
My main computer is the main developer computer in my network. I run a WAMP server on it and some web scripts for testing and development purpose.
Let’s name my main computer to ComputerOne, and every other computers on my LAN to SubComputer.
I wanted to achieve the following: every SubComputers on my network be able to connect to ComputerOne’s WAMP Server and run scripts on ComputerOne.
But I didn’t want to change simply the localhost setting of the SubComputers to the ComputerOne’s LAN IP address (eg. 127.0.0.1 localhost to 192.168.1.2 localhost), because SubComputers also run own WAMP/LAMP server on their own 127.0.0.1 localhost.
So I decided I add a fake domain to ComputerOne’s Apache server, so SubComputers be able to connect to ComputerOne’s WAMP Server through this fake domain.
If you want to achieve a similar system please follow me.
Okay, start it.
Resources on ComputerOne
Op System: Windows 7
Web Server: Apache (WAMP)
Text Editor: notepad
Firewall: Windows Firewall
1, Enable HTTP Port in Windows Firewall on Windows 7
In order to communicate between ComputerOne and SubComputers we need to enable the inbound connection on HTTP port in ComputerOne’s firewall.
To enable that port in Windows Firewall on Windows 7 go to Start Menu>Control Panel>Windows Firewall and select “Advanced Settings”.
In the pop-up window select “Inbound Rules” (right side) and then click “New Rule…” (left side).
Now go through the New Rule Wizard ( I show you the simplest settings).
1.1, In the “Rule Type” window select “Port” and click Next
1.2, In the “Protocol and Ports” window select “TCP” and “Specific local ports” and write “80″ to the field
1.3, In the “Action” window select “Allow the connection”
1.4, In the “Profile” window select “Private” (or you can select all)
1.5, In the “Name” window name your New Rule eg. “HTTP 80 Apache (In)” you can also add some description to your New Rule.
You are done.
Note1: please consider the above settings are basic settings. Setting up a firewall is an advanced task, so please go and read/study the firewall help file extensively.
Note 2: in the 1.4 point I selected only the “Primary” option, moreover I created a new blocking rule for the profile “Public”, so if I connect with ComputerOne to unsecured wireless networks (this is the “Public” network profile in ComputerOne), the computers on this network are not able to connect to ComputerOne’s HTTP port.
If you want, You can also create a blocking rule to the profile “Public”.
Create a New Rule, go through the New Rule Wizard again, only two settings will be different. In the 1.3 point select “Block the connection”, in the 1.4 point select “Public”, that’s all.
Note 3: you should know my LAN is behind a router. And I didn’t open port 80 in my router, so my ComputerOne’s HTTP port is not open/available from the Internet.
But if your LAN is not behind a router, with the above settings your ComputerOne’s HTTP port will be available for anybody (who knows your IP address) from the Internet.
2, Add the fake domain to the Apache config
First, choose a fake domain. I picked “homeserver.home”, but you can select any domain name and extension (or you can drop the domain extension completely eg. “homeserver”).
In ComputerOne open file (use a text editor) “httpd.conf” in folder C:\wamp\bin\apache\Apache2.2.21\conf and find these lines:
# Virtual hosts
Uncomment the second line by removing the symbol # as shown below:
# Virtual hosts
Now open file (use a text editor) “httpd-vhosts.conf” in folder C:\wamp\bin\apache\Apache2.2.21\conf\extra.
Delete all lines and add these lines to the file:
Note: the name of the folder “Apache2.2.21″ is depend on your WAMP server version.
3, Add the fake domain to the hosts files
On ComputerOne open file (use a text editor) “hosts” in folder C:/Windows/System32/drivers/etc and add this line to the file:
Now find your ComputerOne’s LAN IP address:
Open a command prompt (Windows 7 – Start Menu>All Programs>Accessories>Command Prompt), type:
and press enter.
I got the following info:
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::16d:c1cd:8ce2:861a%19
IPv4 Address. . . . . . . . . . . : 192.168.1.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
In my case ComputerOne’s LAN IP address is 192.168.1.2
Now go to your all Windows SubComputers, open file (use a text editor) “hosts” in folder C:/Windows/System32/drivers/etc and add this line to the file:
Note: change 192.168.1.2 to your ComputerOne’s LAN IP address.
If you have any Linux computer, add the line 192.168.1.2 homeserver.home to your Linux distro’s hosts file.
In Debian add the line to /etc/hosts.
5, Restart Apache/WAMP
Now restart Apache or the whole WAMP server on ComputerOne so your new settings take effect.
Go to your computers on your LAN and browse to your fake domain (homeserver.home) in your browser. If everything is OK you will find your WAMP Server’s panel.
Note: If you use other Apache/PHP/MySQL package(eg. EasyPHP, XAMPP) or a standalone Apache installation on ComputerOne you can follow the above steps, but you should find the corresponding Apache conf files in other folders.