Friday, June 3, 2011

Setting Up Node-SPDY

‹prev | My Chain | next›

Up tonight, I try to get my branch of node-spdy up and running on my http://eeecomputes.com Linode. I need to get it running so that the spdy-dev mailing list (specifically Mike Belshe) can help troubleshoot my server push woes.

SPDY requires the relatively new NPN (Next Protocol Negotiation) extension to SSL. So, first up, I install the latest openssl:
cd ~/src/
wget ftp://ftp.openssl.org/snapshot/openssl-SNAP-20110603.tar.gz
tar zxf openssl-SNAP-20110603.tar.gz
cd openssl-SNAP-20110603
Note: I install tarballs in $HOME/src as opposed to $HOME/repos. I reserve the latter for code under source code management.

Note #2: The openssl snapshots are only available for a rolling window of 4 days. In the future, I will check out ftp://ftp.openssl.org/snapshot/ for the most recent snapshot. This is a slight inconvenience, but beats installing CVS.

Next, I configure openssl using the Ubuntu configuration settings that I found worked for 32 and 64 bit:
./Configure shared --prefix=$HOME/local no-idea no-mdc2 no-rc5 zlib  enable-tlsext linux-elf
make depend
make
make install
I install locally, not wanting to mess up the other stuff I have going on that server. To access, I add the following to my .bashrc:
# For locally installed binaries
export LD_LIBRARY_PATH=$HOME/local/lib
PATH=$HOME/local/bin:$PATH
PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig
CPATH=$HOME/local/include
export MANPATH=$HOME/local/share/man:/usr/share/man

# For node.js work. For more info, see:
# http://blog.nodejs.org/2011/04/04/development-environment/
for i in $HOME/local/*; do
[ -d $i/bin ] && PATH="${i}/bin:${PATH}"
[ -d $i/sbin ] && PATH="${i}/sbin:${PATH}"
[ -d $i/include ] && CPATH="${i}/include:${CPATH}"
[ -d $i/lib ] && LD_LIBRARY_PATH="${i}/lib:${LD_LIBRARY_PATH}"
[ -d $i/lib/pkgconfig ] && PKG_CONFIG_PATH="${i}/lib/pkgconfig:${PKG_CONFIG_PATH}"
[ -d $i/share/man ] && MANPATH="${i}/share/man:${MANPATH}"
done
Next up, I install node.js. NPN is not in the most recent version of node.js (0.4.8), so I have to install the pre-release from github:
cd ~/repos/
git clone https://github.com/joyent/node.git
cd node
Then I configure and install node:
./configure --openssl-includes=$HOME/local/include --openssl-libpath=$HOME/local/lib --prefix=$HOME/local/node-v0.5.0-pre
make
make install
It needs to be configured so that it uses the NPN-enabled openssl that I just installed in my ~/local directory. It also needs to be configured to install into a ~/local sub-directory (which will be picked up by my new .bashrc paths).

I then install npm and the required connect and zlibcontext packages:
curl http://npmjs.org/install.sh | sh
npm install zlibcontext
npm install connect
Lastly, I clone my node-spdy repository (and checkout the push-stream branch where I have been experimenting with SPDY push streams):
git clone git://github.com/eee-c/node-spdy.git
git checkout -b push-stream -t origin/push-stream
With that, I can change directory into node-spdy and fire up the test server:
cd node-spdy
node ./test/spdy-server.js
TLS NPN Server is running on port : 8081
And that is all there is to it.

Day #39

No comments:

Post a Comment