Friday, December 31, 2010

Hosting Content on the World Wide Web on a Laptop

I have a Macbook Pro (MBP) running Snow Leopard. It is connected to the internet through a wireless router. I am running MAMP on it and using it as a server, and I access the server from the iPhone, or the iPad, from WITHIN the LAN (behind the router) via the Wi-Fi connection to that router. Wouldn't it be nice to be able access that same server remotely, from OUTSIDE the LAN, via, say, a 3G connection?

Three steps to doing this:
1. Find out what the IP address is (whatismyip.com)
2. Tell the ROUTER to assign a static IP address to the MBP within the LAN
login to router as admin ->LAN setup->Use Router as DHCP Server->Address Reservation
In my case, I just selected the address it had randomly assigned to make it permanent (192.168.1.18)
You need to know your computer's name and/or mac address to do this, so that you select the correct computer.
3. Then you need to go to port forwarding (still in admin in the ROUTER settings), and assign start port 8888 to forward to end port 8888 on 192.168.1.18.

Finally, step outside the LAN and browse to:
ipaddress:8888/homefolder/index.php
and you are there.

CAUTION: if you do this and leave your server on, your precious MBP is on the world wide web, and can be subject to cyber attack. It helps that the port is not 80, or 8080, which are far more common, but still, take precautions.

No comments:

Post a Comment