Mark Jaroski at 2013-07-07T09:37:30Z

How to use Voyageur's Apache websocket backport with

As I mentioned in a previous post I'm running a couple of other services from my machine on paths below root which is why I wanted to use a reverse proxy in the first place. Otherwise I'd have probably just gone with Evan's admonition against them. My setup is Ubuntu 13.04 (Raring) on an older system76 laptop. The Apache provided with Raring is 2.2, and I expect that to be the case for some time.

Thankfully Bernard Cafarelli (Voyageur) published a patch backporting websocket proxy support to Apache 2.2 back in late April, so I thought I'd try to get it to work with my setup, and am happy to report that it works! Here's what I did:

The first step is to get the patch and to compile the module. Voyageur's patch is here. Yes, both the title of the patch and the file references inside refer to Apache 2.4, but that's because it's a backport (of a backport). It does work with 2.2.

So my next step was to get a copy of the sources. I did this the Debian way:

mkdir -p ~/src

cd ~/src
apt-get source apache2

You might also need to fetch some build dependancies:

apt-get build-dep apache2
apt-get install autoconf

My first impulse was to try to build a Debian package containing the module, but after playing with it for a while I realized that this was overkill. All I really needed was a binary module which would work with the 2.2 series. This works because Apache is designed to support binary modules, so long as they are within series.

So it's possible to just skip the package-buiding, and instead just apply the patch, configure, and build. So long as your apache has DSO support you don't even need to use a simlar configuration:

NOTE: check your paths, they might be different from mine

cd ~/src/apache2-2.2.22
patch -p1 -i ~/downloads/apache-2.2.24-wstunnel.patch
autoconf # this is key: you need an updated configure script!
./configure --enable-so --enable-proxy=shared --enable-proxy-wstunnel=shared

You should now find a shiny new websocket proxy module in modules/proxy/.libs. You need to copy this into your system apache modules directory:

cp modules/proxy/.libs/  /usr/lib/apache2/modules/

It probably makes sense to copy it to a second location as a backup as well, but given the way the package management system works it will be safe there until the module appears in some future Debian package, in which case you want it to be overwritten anyway.
Now it's just a matter of configuring apache. First I added a .load file: /etc/apache2/mods-available:/
# Depends: proxy
LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/

And enabled the module with a symlink:
cd /etc/apache2/mods-enabled
ln -s ../mods-available/proxy_wstunnel.load
And finally I added a location stanza to map proxy requests. I found the location in my httpd access logs:

<Location /main/realtime/sockjs>

        ProxyPass wss://
        ProxyPassReverse wss://

Then a sanity check:
apachectl confgitest
Presuming that's good then you should be able to restart apache and all will be well. I used the init script:
/etc/init.d/apache2 restart
So far the biggest benifit seems to be a slight speed improvement in the pseudo authentication handshake. There are probably some other things that work better, but mainly I just didn't want to run pump with one of its main protocols disabled.
Hopefully this will be useful for somebody. Have fun!

sebastianconcept, Stephen Sekula likes this.

Stephen Sekula shared this.

Show all 8 replies
I've always thought of a2enmod as an abstraction layer which is meant to be run from postinst scripts. The idea is that the packagers can move things around without breaking scripts because all they have to do is edit a2enmod. If you're doing stuff manually it doesn't really save you any time though because all it does is ln -s ../mods-avaliable/<x>.load

Mark Jaroski at 2013-07-08T07:57:17Z

I have the same apache version as you, albeit on Ubuntu 12.04. After following the build instructions, installing the module, and then running the Apache config test, I got this error: undefined symbol: ap_proxy_pass_brigade. Any hints or leads on that problem? A google search turned up little of use...

Stephen Sekula at 2013-07-09T07:55:01Z

Hmmm. That's defined in the patch itself, in mod_proxy.h. Ahhhhh, I see. It's my mistake, I think. Try copying all of the proxy modules built after the patch. To the Apache libs dir. If that works then I'll have to update my post (again).

Mark Jaroski at 2013-07-09T12:57:11Z

Awesome. Made my day.

Notes: I've tried at first on apache 2.2.14 and it doesn't work. The patch fails in two places and from there nothing goes well.

Using apache2-2.2.22 it's all good once you put the  and in the modules folder

PS: congrats for sounds appealing to make social aggregators

sebastianconcept at 2013-10-25T21:46:31Z