Apache 2.2 Websocket Proxying on Ubuntu with mod_proxy_wstunnel

6 June 2013

Until recently, I was running a Node.js web application using Websockets with socket.io alongside an Apache web server. I wanted Apache to run on port 80 and serve both sites using name-based virtual hosting. However, Apache httpd mod_proxy couldn’t proxy Websockets correctly.

I discovered that there is a new mod_proxy_wstunnel module in the Apache httpd source trunk in an article describing how to backport mod_proxy_wstunnel to Apache 2.4 or 2.2. I figured out the specific steps for doing this on Ubuntu (tested on 11.10 with Apache httpd 2.2.20). I wanted to add them as a comment, but they were disabled on that blog.

Here are the steps, see the original blog post of the patch author for more information:

# Check apache version (should be 2.2.20 as of writing, if not adjust the next step)
dpkg -s apache2

# Checkout apache source
svn checkout http://svn.apache.org/repos/asf/httpd/httpd/tags/2.2.20/ httpd-2.2.20

# Get patch and apply it
wget http://cafarelli.fr/gentoo/apache-2.2.24-wstunnel.patch
cd httpd-2.2.20
patch -p1 < ../apache-2.2.24-wstunnel.patch

# Build Apache 
svn co http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x srclib/apr
svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.3.x srclib/apr-util
./buildconf # EDIT: Some commenters noted that buildconf should be run before the configure
./configure --enable-proxy=shared --enable-proxy_wstunnel=shared
make

# Copy the module and recompiled mod_proxy (for new symbols) to the ubuntu apache installation and update the permissions to match the other modules
sudo cp modules/proxy/.libs/mod_proxy{_wstunnel,}.so /usr/lib/apache2/modules/
sudo chmod 644 /usr/lib/apache2/modules/mod_proxy{_wstunnel,}.so
echo -e "# Depends: proxy\nLoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so" | sudo tee -a /etc/apache2/mods-available/proxy_wstunnel.load

# Enable the module (also make any configuration changes you need)
sudo a2enmod proxy_wstunnel
sudo service apache2 restart

Apache 2.2 Websocket Proxying on Ubuntu with mod_proxy_wstunnel - Comments

VisualVM Executable Location for Eclipse on OS X Mountain Lion

16 April 2013

/Applications/VisualVM.app/Contents/Resources/visualvm/bin/visualvm


VisualVM Executable Location for Eclipse on OS X Mountain Lion - Comments

Fix PDF line breaks for copy and paste

16 April 2013

Format text copied from a PDF to try and remove unwanted line breaks.

See the page to format text copied from a PDF.


Fix PDF line breaks for copy and paste - Comments

Ubuntu: Running a command in GNU screen on boot as another user

14 January 2013

Add to /etc/rc.local before the ‘exit 0’ line:

mkdir /var/run/screen
chmod 775 /var/run/screen
chgrp utmp /var/run/screen
su USER -c 'screen -m -d -S SCREENNAME bash -c "COMMAND"'

Replace USER with the user you want the command to run as. SCREENNAME with any name you like, and COMMAND with the actual command to run in the screen.

The first three lines were necessary to work around a bug in screen on Ubuntu.


Ubuntu: Running a command in GNU screen on boot as another user - Comments

Getting URLs to line break in LyX

4 January 2013

LyX is generally pretty good, but sometimes things that should be simple can be a pain. I couldn’t successfully get long URLs to wrap over multiple lines rather than overflowing off the edge of the page until I read this obscure bug report after about 5 minutes of Googling.

What worked for me was using Insert->URL instead of Insert->Hyperlink. Simple as that, I didn’t even notice there were two different options previously.

As a bonus you can make URLs clickable in PDFs by going to Document->Settings->PDF Properties->Use Hyperref Support.


Getting URLs to line break in LyX - Comments