Routing requests to local development environment
Some third party systems needs to send requests to your web application in order to work.
That’s fine in production where you have a public facing webserver running, but when you’re developing locally you have to jump through a few hoops.
Reverse SSH tunnel
The common approach is to setup a SSH tunnel on a remote server and use that as endpoint for the third party service. This is pretty standard business and can be handled by a service like Showoff. Personally I just use basic SSH:
ssh -vN email@example.com -R 3000:localhost:3000
As long as the above is running, all requests to port 3000 on example.com is received on localhost:3000.
While it is possible to setup the tunnel on port 80 remotely, my servers tend to already occupy port 80, so that’s a no go.
The next piece of the puzzle then becomes routing to the SSH tunnel at port 3000 from port 80.
<VirtualHost *:80> ServerName tunnel.example.com ProxyPass / http://0.0.0.0:3000/ retry=0 </VirtualHost>
(The retry=0 option to ProxyPass prevents the endpoint from being marked as bad for a period of time if it receives a request without my tunnel being active)
With this in place, any request to tunnel.example.com is passed to 0.0.0.0:3000 on the same server, where the SSH tunnel receives it and passes it to my local development server.
Success! And the best part is, this totally makes me feel like I am bouncing connections around in Uplink.