The Golden Spot

I hope this helps someone who is learning about Linux and web application programming with Python, Django, and Javascript.

Wednesday, September 21, 2011

Forward LAN traffic to localhost web server on the same MacBook Pro

Using a stock, early 2011 model MacBook Pro, I needed to access my secure webserver, which runs on localhost and the default port for HTTPS of 443 (, with remote clients on the LAN. The LAN at my home office is

The following assumes you have edited httpd.conf and have HTTPS configured correctly; that is, you are able to  point a web browser to and see the site you are serving with httpd.

1) Turn on Web Sharing in System Preferences/Sharing. This will open a port on the LAN for httpd to serve requests.
2) Turn on Remote Login in System Preferences/Sharing. This will start sshd to enable port forwarding with ssh at the command line.
3) Using a shell enter:
ssh -NL your_username@localhost

a ) is the address of my laptop's interface on the LAN.
b ) 8080 is the port that ssh will listen to and then forward traffic to and from.
c ) is the address:port on my laptop that ssh will forward traffic to, when it receives traffic on
d ) your_username@localhost is the login for the local sshd service that was started by enabling Sharing/Remote Login in System Prefernces

By visiting on the network with say, an iPhone, you will be able to see the website that is configured in httpd as on the MacBook. This helps with local development since you don't have to create a new cert each time your dynamic LAN address changes; it is only a matter of changing the address and port that ssh will forward to localhost.