Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The WebSocket protocol is an extension of the HTTP protocol. However, the proxy module of Apache2 does not seem to know about it, and throws away crucial headers, converting the call to a standard HTTP call.

Is there a way to make Apache2 either (1) understand WebSocket or (2) simply blindly pass on whatever it gets?

share|improve this question

There is now a module in the Apache trunk called mod_proxy_wstunnel which allows mod_proxy (ProxyPass/ProxyPassReverse) to pass through WebSocket traffic. Someone wrote a blog post about back-porting mod_proxy_wstunnel to Apache 2.4/2.2 and provided a patch to do so.

I figured out concrete instructions to set up mod_proxy_wstunnel on Ubuntu (tested with Ubuntu Server 11.10 and Apache 2.2.20) and posted them on my blog. I have copied them below:

# 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 httpd-2.2.20

# Get patch and apply it
cd httpd-2.2.20
patch -p1 < ../apache-2.2.24-wstunnel.patch

# Build Apache 
svn co srclib/apr
svn co srclib/apr-util
./configure --enable-proxy=shared --enable-proxy_wstunnel=shared

# 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/" | 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
share|improve this answer
When I followed your guide, there was a step that you didn't have. After doing the apr checkouts I had to run ./buildconfig to create the configure file. And there were a couple dependencies that it told me to install. – notbad.jpeg Aug 28 '13 at 16:47
does this hook up with Glassfish 4 over wss: (SSL) – Archimedes Trajano Jun 26 '14 at 1:56
@notbad.jpeg: You probably mean ./buildconf (not ./buildconfig) :-) – Erik Forsberg Jan 20 '15 at 8:30
Just my feedback... this installed and loaded in apache 2.2.22-1ubuntu1.10 from Ubuntu 12.04, but it didn't work for me in the end. The proxy was removing the "Upgrade" header (the source code says "RFC2616 13.5.1 says we should strip these headers"), which is a header the server expects, not just one hop, so it didn't work for me, and I have replaced it with an iptables DNAT rule instead. – Peter Feb 10 at 9:58

There is nothing to indicate Apache httpd will support them anytime soon.

If you must run websockets through apache, try mod_pywebsocket. I have tried it, and it does work.

Here are a few alternatives I prefer:

share|improve this answer

Looks like with a combination of the disconnect plugin and some extra code this is now possible:

share|improve this answer

Please take a look at

The apache-websocket module is an Apache 2.x server module that may be used to process requests using the WebSocket protocol by an Apache 2.x server.

share|improve this answer
I looked at the above github project. It does not act as proxy. quote The module consists of a plugin architecture ... – guettli Dec 18 '13 at 10:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.