Building mod_proxy_wstunnel for CentOS 6

I had a need to be able to put an Apache-based reverse proxy in front of an install of Uchiwa which is a Node.js-based dashboard for Sensu. The only problem is that it uses WebSockets which means it doesn’t work with the regular mod_proxy_http module. In version 2.4.5 onwards there is mod_proxy_wstunnel which fills in the gap however CentOS 6 only has a 2.2.15 (albeit heavily patched) package.

There are various instructions on how to backport the module for 2.2.x (mostly for Ubuntu) but these involve compiling the whole of Apache from source again with the module added via an additional patch. I don’t want to maintain my own Apache packages but more importantly Apache has provided apxs a.k.a the APache eXtenSion tool to compile external modules without requiring the whole source tree available.

So, I have created a standalone RPM package for CentOS 6 that just installs the mod_proxy_wstunnel module alongside the standard httpd RPM package. In order to do this I took the original patch and removed the alterations to the various build files and also flattened the source into a single file, (the code changes were basically adding whole new functions so they were fine to just inline together). The revised source file and accompanying RPM spec file are available in this Github gist.

Tags: , , , , , , , ,

12 Responses to “Building mod_proxy_wstunnel for CentOS 6”

  1. Mark V. says:

    I’ve updated your gist to compile on Apache 2.4.6 (jul 2014). Not sure how long it’ll last till new update breaks it again šŸ™‚

    • Matt says:

      Cool, but this module has been part of the main Apache source since 2.4.5 according to so I’m wondering if you’re trying to fix a slightly different problem.

      • Mark V. says:

        I guess so. I’ve just updated my centos to 6.6 and when i query httpd -v it says 2.4.6 but it doesn’t have this mod. And yum repos don’t have it either, so that’s why i had to recompile it. I didn’t know 2.4.6 is supposed to have it, i’ll do more research. Thank you for pointing it out !

        • Matt says:

          Yes, I think you’re just battling with packaging decisions or policy; it’s there in the source tree but just hasn’t been enabled.

          I’m curious where you’re getting the 2.4.6 package from though as my CentOS 6.6 machines still have 2.2.15, unless 2.4.x is available in the Software Collections repositories? It might be worth trying to raise a ticket with the packager to get them to enable the module in their build.

          • Mark V. says:

            argh, i must have compiled this from source sometime ago and forgot. Anyway, i found Centos 7 has it, wstunnel is present there, so i’ll do an upgrade instead of mucking with it šŸ™‚ — regardless, thank you for your guidance, your questions made me think in the right direction.

          • Matt says:

            For reference I found out there is indeed an httpd24 Software Collection for CentOS 6 and the main httpd24-httpd package has compiled and available.

  2. BenDon says:


    Thanks a lot: nice hack.

    It bought me some precious time before upgrading to CentOS 7…
    But I think I’ve hit a small bug that annoyed me a lot: PR 56299
    See here:

    Each time a client was closing the ws, apache was logging a 500 and sending “internal server error” html in response body back to the client.
    From an appliaction point of view, most client do not care (browsers dev tools/console don’t bother to show it neither! I had to use a sniffer to see it).
    However, mod_security was logging massively those 500 without any corresponding event in the error log.

    So I took on me to try to backport 2 fixes committed in tag 2.4.10 (PR 56299 and PR 55890).

    It works apprently fine for me with httpd-2.2.15-39.el6.centos.x86_64 and

    Here is the fork:

  3. Werner Maes says:


    Will this also work with more recent versions of httpd onder Centos 6.x?

    Kind regards

    • Matt says:

      CentOS/Red Hat rarely change the base version of a package within a major version of the OS so unless they’ve also backported this module or jumped to a newer version of Apache I would expect it to work still. I haven’t used this for a while so I don’t have a definitive answer.

  4. Ram says:


    thanks for the work. Look like it is going to solve my problem with configuring nodebb. I am struck with apache 2.2.15 and need mod_proxy_wstunnel.

    Since I am very new to Linux I don’t know how to build/install packages from source. Could you please guide me on using these source files. I am on CentOS 6.8

    Thanks in advance

  5. Werner Maes says:

    Correction to my previous post

    If I use
    ProxyPass /apc/ wss://xxxx:8498/apc/ in your apache config

    I always get this error

    WebSocket-dbg.js:376 WebSocket connection to ‘wss://xxxx/demo_apc’ failed: Connection closed before receiving a handshake response

    If I use
    ProxyPass /apc/ ws://xxxx:8098/apc/

    it works fine (with the fork from

    So only ws:// works fine not wss://


Leave a Reply