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: , , , , , , , ,

10 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 šŸ™‚

    https://gist.github.com/MarianVasile/b93a01962d0cbe011a2b

    • Matt says:

      Cool, but this module has been part of the main Apache source since 2.4.5 according to http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html 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 mod_proxy_wstunnel.so compiled and available.

  2. BenDon says:

    Hi,

    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: https://github.com/apache/httpd/commit/fa6d270ca477edf2dfaab2533889f33597a84187

    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 mod_security-2.8.0-24.el6.art.x86_64.

    Here is the fork: https://gist.github.com/btlogy/58863377eafcf4575a1e

  3. Werner Maes says:

    Hello

    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.

Leave a Reply