Apache Reverse Proxy + SSH Reverse Tunnel

Disclaimer: This setup is just a bit crazy, and I wouldn’t recommend it for a production site. Works for me.
I needed to allow some clients to test a web app I’m working on. But I didn’t want to deploy the code to a server for now for different reasons (mainly memory constraints). So the solution was to setup a reverse proxy using apache to my local machine. Check out the code after the break
Here’s the VirtualHost I created:


	ServerName proj312.grat.in
	ProxyPass / http://home-ip:18000/
	ProxyPassReverse / http://home-ip:18000/

The problem is that my home-ip is not fixed. A Dynamic DNS setup is the fix that comes to mind first. But, I thought I would try something else: Reverse SSH Tunnel
I used the recipe and explanations in this article. Mostly, all I needed to do was the following:

ssh -fNR 18000:localhost:8000 myserver

Where the 18000 is the port on the server, and 8000 is the port on the home machine. No harm in using the same port numbers, btw.

I then changed the VirtualHost configuration in apache on the server to read:


	ServerName proj312.grat.in
	ProxyPass / http://127.0.0.1:18000/
	ProxyPassReverse / http://127.0.0.1:18000/

Restart apache on the server and all falls in place perfectly.

Similar Posts:

Tagged , , , , , ,

One thought on “Apache Reverse Proxy + SSH Reverse Tunnel

  1. Seb says:

    This is brilliant, thank you!
    I now have a server behind firewall acting as the local test server, but it can be accessed from the outside if needed when working from home or so.

Leave a Reply

Your email address will not be published. Required fields are marked *