elfs: (Default)
[personal profile] elfs
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.

Date: 2011-12-01 12:44 am (UTC)
ext_345282: (Default)
From: [identity profile] orcaarrow.livejournal.com
Reading your coding posts always makes me realize how little I truly know or understand!

Date: 2011-12-01 07:31 pm (UTC)
From: [identity profile] elfs.livejournal.com
I don't think this one is that weird or hard to understand. Nginx happily admits it buffers all uploads before sending them on to internal services. Node.js's documentation says "The interface is careful to never buffer entire requests or responses--the user is able to stream data." The solution to my problem is right there.

I always think that knowing this stuff is a matter of saying, "What do I want? What do I have to know to do it? And where do I go to find out?" Sometimes, you have to practice. The switchboard problem (which I've kept on github, and updated to reflect the new things I've learned) is a sign of me embracing my suck (http://sarahwagneryost.com/why-its-so-awesome-that-you-suck/), as we say in the geek business.

Date: 2011-12-02 01:41 am (UTC)
ext_345282: (Default)
From: [identity profile] orcaarrow.livejournal.com
I don't think your coding is too difficult to understand. I am not versed in the protocols and I know nothing of IP, Javascript, or almost anything that I would need to know for actual usefulness in the modern coding world. I only programmed in PASCAL and Assembler.

I am totally impressed by your knowledge of and ability to navigate the systems you are in.

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 28th, 2025 06:11 am
Powered by Dreamwidth Studios