Publishing negative results...

Nov 30, 2011 12:44

The other day, I blogged proudly about a piece of code called Switchboard, which allowed you to create a reverse proxy with routes decided by URL rather than host. Nginx does this, but it only has HTTP/1.1 <-> HTTP/1.0 proxying and no control over buffer sizes. Varnish does all 1.1, but no SSL. Pound buffers uploads completely to RAM before forwarding. So I wrote Switchboard.

It turns out Switchboard is a massive hack to get around three bugs in the nodejitsu node-http-proxy library, which is what Switchboard uses. Once I realized this, I submitted three patches to the nodejitsu team, and have happily admitted that my code was a monstrous hack. A much smaller piece of code, two functions, each less than ten lines long, was all that was needed to replace the entire functionality of that 161-line monstrosity.

I'm very pleased with the results, however: I can now do HTTP/1.1 <-> HTTP/1.1 reverse proxying, have complete control over my upload buffer size, and can maintain proxied websockets and socket.io communications channels.

geek

Previous post Next post
Up