I had a pain at work: develop code to take actions based on Stripe webhooks. Why was it a pain? Well, how could Stripe send a webhook to my http://127.0.0.1:3000? I know some people will say that I can mock, stub, etc, but I like to see it working at least once, to make sure everything is alright. After a little bit of googling I stumbled upon a tool called Ngrok.
Ngrok’s premise is awesome: it gives you an URL that will forward traffic to your localhost on any port you want. So, I downloaded the executable, followed the instructions but unfortunately I could not get it to work. Maybe something with my laptop, or maybe some temporary failure on Ngrok’s servers… who knows? I want to register here that Ngrok is a great tool, used by many people. It has some neat features like replay requests. But I got a little frustrated and decided to solve the problem myself. Also because I’m always up for a new challenge, and I love building things. So, I decided to create a tool that would allow me to do the same, but without the download requirement.
I managed to put together a Rails app that helps me create SSH reverse tunnel commands on a simple and easy to use graphical interface, and use Nginx to reverse proxy requests to the SSH tunnel port. The interface would automatically setup Nginx virtualhosts (server blocks) for me, and give me random URL’s of my personal domain.
Now, all I have to do is figure out a way to not have to type giant SSH commands in a terminal window every time I want to open a tunnel. I thought: how can I solve that problem, and make it work on any computer I want? That’s when the swiss army knife of sysadmins came in handy: Bash! (sorry Windows users, no luck for you, unless you use cygwin)
So, instead of typing a large SSH command inside a terminal window, all I have to do now is to paste a CURL command generated by my app, and pipe the output to bash -s, and voilà! The output of the CURL command has all I need to start the tunnel, plus some nice features like reopen the tunnel if the connection drops. CURL will use a unique URL, randomly generated to avoid security problems.
Will it work?
So, it’s time to test. Tunnel created via web interface. Check. Paste a command on a terminal window and open the tunnel. Check. Random URL generated. Check. All I have to do is to tell stripe to send webhooks to that URL. And it worked like a charm!!!
This app solved a huge pain for me. Turns out that it solved a different pain for my coworkers – quickly showing each other what they are working on, without having to memorize IPs or setup DNS.
After that I decided to give it a name and put it online: https://burrow.io.
Go check it out and let me know how Burrow solves a problem for you!