{"id":910,"date":"2014-12-05T11:15:52","date_gmt":"2014-12-05T16:15:52","guid":{"rendered":"https:\/\/www.softwareab.net\/wordpress\/?p=910"},"modified":"2014-12-05T11:18:49","modified_gmt":"2014-12-05T16:18:49","slug":"backport-websockets-apache-2-2-x86","status":"publish","type":"post","link":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/","title":{"rendered":"Backport Websockets to Apache 2.2 (x86!)"},"content":{"rendered":"<p>Hello all &#8211; today&#8217;s post is on backporting Websockets to an ancient PE2650 running CentOS 6.6. Yup&#8230;i686 in all its glory. Read on for our solution!<\/p>\n<p><!--more--><\/p>\n<p>The problem? We have a <a href=\"http:\/\/shiny.rstudio.com\/\">Shiny<\/a> app that uses <a href=\"http:\/\/en.wikipedia.org\/wiki\/WebSocket\">Websockets<\/a>. But we are proxying access to the Shiny app (via the <a href=\"http:\/\/www.rstudio.com\/products\/rstudio\/download-server\/\">R Server<\/a>) from a front-end Apache. And &#8211; as we all know &#8211; on CentOS standard yum repositories only go up to Apache 2.2 (2.2.15 currently). And Websockets is supported &#8211; via <a href=\"http:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_proxy_wstunnel.html\">mod_proxy_wstunnel<\/a> &#8211; only in Apache 2.4.<\/p>\n<p>Hmmm. So what to do? Backport the fix in, of course!<\/p>\n<p>Here are our steps:<\/p>\n<ol>\n<li>See following resources; we modify them heavily  to meet our CentOS 6.6 i686 environment:\n<ul>\n<li>http:\/\/serverfault.com\/questions\/290121\/configuring-apache2-to-proxy-websocket<\/li>\n<li>https:\/\/issues.apache.org\/bugzilla\/show_bug.cgi?id=49053<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Continue to the next step.<\/p>\n<li>\nInstall Apache for CentOS:<\/p>\n<pre><code>sudo yum install httpd\r\nchkconfig httpd24-httpd on\r\nservice httpd24-httpd start\r\n<\/code><\/pre>\n<p>Continue to the next step.\n<\/li>\n<li>\nInstall necessary packages to base CentOS and setup firewall to permit HTTPS. Note that we are *not* running as <code>root<\/code>:<\/p>\n<pre><code>sudo yum install -y patch autoconf libtool\r\nsudo yum install -y httpd mod_ssl mod_proxy_html\r\nsudo iptables -I INPUT 2 -p tcp -m state --state NEW -m tcp \\\r\n  -m multiport --dports 80,443 -m comment --comment \"HTTP\/HTTPS\" -j ACCEPT\r\nsudo service iptables reload\r\nsudo service iptables save<\/code><\/pre>\n<p>Note that <code>libtool<\/code> is version 2.0 while Apache source (specifically, <code>apr-utils<\/code>) was built for <code>libtool<\/code> version 1. We will address that problem below.<\/p>\n<p>On the firewall: Be sure to do the same for the VM Security Group if running virtually.<\/p>\n<p>Continue to the next step.\n<\/li>\n<li>\nCreate the dev tree to do your work. We&#8217;re running our builds locally:<\/p>\n<pre><code>mkdir -p ~\/proj\/websockets\r\ncd ~\/proj\/websockets<\/code><\/pre>\n<p>Continue to the next step.\n<\/li>\n<li>\nDownload packages and patches to build Apache 2.2.15 (which matches the CentOS Apache distro):<\/p>\n<pre><code>wget https:\/\/archive.apache.org\/dist\/httpd\/httpd-2.2.15.tar.gz\r\nwget https:\/\/archive.apache.org\/dist\/apr\/apr-util-1.5.4.tar.gz\r\nwget https:\/\/archive.apache.org\/dist\/apr\/apr-1.5.1.tar.gz\r\nwget http:\/\/people.apache.org\/~rjung\/patches\/expat-libtool2.patch\r\nwget https:\/\/gist.github.com\/vitkin\/6661683\/raw\/873dd8b4de4ad1ff69757ffe48fc574374aedc57\/apache-2.2-wstunnel.patch<\/code><\/pre>\n<p>Continue to the next step.\n<\/li>\n<li>\nExtract files and apply patches:<\/p>\n<pre><code>tar zxf httpd-2.2.15.tar.gz\r\ncd httpd-2.2.15\r\npatch -p1 -i ..\/apache-2.2-wstunnel.patch\r\ncd srclib\/apr\r\ntar xzf ..\/..\/..\/apr-1.5.1.tar.gz\r\ncd ..\/apr-util\/\r\ntar xzf ..\/..\/..\/apr-util-1.5.4.tar.gz\r\npatch -p1 -i ..\/..\/..\/expat-libtool2.patch\r\ncd ..\/..\/..<\/code><\/pre>\n<p>Continue to the next step.\n<\/li>\n<li>\nConfigure and build system. Note we build all the dependent modules as our production environment requires them.<\/p>\n<pre><code>.\/buildconf\r\n.\/configure --enable-proxy=shared --enable-proxy_ajp=shared \\\r\n  --enable-proxy_balancer=shared --enable-proxy_connect=shared \\\r\n  --enable-proxy_ftp=shared --enable-proxy_http=shared \\\r\n  --enable-proxy_wstunnel=shared\r\nmake<\/code><\/pre>\n<p>Continue to the next step.\n<\/li>\n<li>\nInstall the compiled mod_proxy over the base (saving the original for the first run). You can run these commands as-is any number of times.<\/p>\n<pre><code>[ ! -d \/usr\/lib\/httpd\/modules\/bak ] && sudo mkdir \/usr\/lib\/httpd\/modules\/bak\r\nl_lib=\/usr\/lib\/httpd\/modules; l_lib_loc=modules\/proxy\/.libs\r\nl_sos=''; for i in $(ls $l_lib_loc\/*.so); do l_sos=\"$l_sos $(basename $i)\"; done\r\nfor i in $l_sos; do [ ! -f $l_lib\/bak\/$i ] && sudo cp $l_lib\/$i $l_lib\/bak\/; done\r\nfor i in $l_sos; do yes | sudo cp $l_lib_loc\/$i $l_lib\/; sudo chmod 755 $l_lib\/$i; done<\/code><\/pre>\n<p>service httpd restart<br \/>\nContinue to the next step.\n<\/li>\n<li>\nModify your Apache config file; here we create a new file to hold our Websockets process:<\/p>\n<pre><code># \/etc\/httpd\/conf.d\/z-websockets-demo.conf\r\nLoadModule proxy_wstunnel_module modules\/mod_proxy_wstunnel.so\r\n\r\n&lt;VirtualHost *:80&gt;\r\n  ServerName websockets-demo.hlsdev.com\r\n  ProxyRequests Off\r\n  ProxyPreserveHost Off\r\n  &lt;Proxy *&gt;\r\n    Order allow,deny\r\n    Allow from all\r\n  &lt;\/Proxy&gt;\r\n\r\n  # websockets?\r\n  ProxyPassMatch ^\/(.*\/__sockjs__\/[0-9]+\/.*) ws:\/\/backend.example.local:3838\/$1\r\n  ProxyPass \/  http:\/\/backend.example.local:3838\/ max=1 disablereuse=on keepalive=on\r\n  ProxyPassReverse \/ http:\/\/backend.example.local:3838\/\r\n  CustomLog \/var\/log\/httpd\/demo.log combined\r\n  ErrorLog  \/var\/log\/httpd\/demo_error.log\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>In the above: the Websockets support is provided by two additional lines. The first line loads the Websockets Tunneling code (which is an add-on to standard ws-proxy module):<\/p>\n<pre><code>LoadModule proxy_wstunnel_module modules\/mod_proxy_wstunnel.so<\/code><\/pre>\n<p>The second line performs the check for the \u201cwebsocketized\u201d application using the ProxyPassMatch command. The regular expression checks for __socksjs__ followed by an all-numeric identifier. If found, then the proxy will send the request to the \u201cws:\/\/\u201d destination, which automagically invokes the ws_tunnel code.\n<\/li>\n<\/ol>\n<p>That is all. The proxy now works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello all &#8211; today&#8217;s post is on backporting Websockets to an ancient PE2650 running CentOS 6.6. Yup&#8230;i686 in all its glory. Read on for our solution!<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77,1],"tags":[42,18,79],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Backport Websockets to Apache 2.2 (x86!) - softwareab<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Backport Websockets to Apache 2.2 (x86!) - softwareab\" \/>\n<meta property=\"og:description\" content=\"Hello all &#8211; today&#8217;s post is on backporting Websockets to an ancient PE2650 running CentOS 6.6. Yup&#8230;i686 in all its glory. Read on for our solution!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\" \/>\n<meta property=\"og:site_name\" content=\"softwareab\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cloudraticsolutions\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/cloudraticsolutions\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-05T16:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-12-05T16:18:49+00:00\" \/>\n<meta name=\"author\" content=\"Andrew Bruce\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@realcloudratics\" \/>\n<meta name=\"twitter:site\" content=\"@realcloudratics\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andrew Bruce\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\"},\"author\":{\"name\":\"Andrew Bruce\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\"},\"headline\":\"Backport Websockets to Apache 2.2 (x86!)\",\"datePublished\":\"2014-12-05T16:15:52+00:00\",\"dateModified\":\"2014-12-05T16:18:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\"},\"wordCount\":402,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\"},\"keywords\":[\"centos\",\"sysadmin\",\"websockets\"],\"articleSection\":[\"Apache\",\"Teknocratica\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\",\"url\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\",\"name\":\"Backport Websockets to Apache 2.2 (x86!) - softwareab\",\"isPartOf\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#website\"},\"datePublished\":\"2014-12-05T16:15:52+00:00\",\"dateModified\":\"2014-12-05T16:18:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.softwareab.net\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"centos\",\"item\":\"https:\/\/www.softwareab.net\/wordpress\/tag\/centos\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Backport Websockets to Apache 2.2 (x86!)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#website\",\"url\":\"https:\/\/www.softwareab.net\/wordpress\/\",\"name\":\"softwareab\",\"description\":\"Technocratica, Technopolitik, Technophobia\",\"publisher\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.softwareab.net\/wordpress\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\",\"name\":\"Andrew Bruce\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.softwareab.net\/wordpress\/wp-content\/uploads\/2024\/03\/andy-cartoon.jpg\",\"contentUrl\":\"https:\/\/www.softwareab.net\/wordpress\/wp-content\/uploads\/2024\/03\/andy-cartoon.jpg\",\"width\":400,\"height\":330,\"caption\":\"Andrew Bruce\"},\"logo\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/image\/\"},\"description\":\"Team-oriented systems mentor with deep knowledge of numerous software methodologies, technologies, languages, and operating systems. Excited about turning emerging technology into working production-ready systems. Focused on moving software teams to a higher level of world-class application development. Specialties:Software analysis and development...Product management through the entire lifecycle...Discrete product integration specialist!\",\"sameAs\":[\"http:\/\/cloudraticsolutions.net\/\",\"https:\/\/www.facebook.com\/cloudraticsolutions\/\",\"https:\/\/twitter.com\/realcloudratics\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Backport Websockets to Apache 2.2 (x86!) - softwareab","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/","og_locale":"en_US","og_type":"article","og_title":"Backport Websockets to Apache 2.2 (x86!) - softwareab","og_description":"Hello all &#8211; today&#8217;s post is on backporting Websockets to an ancient PE2650 running CentOS 6.6. Yup&#8230;i686 in all its glory. Read on for our solution!","og_url":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/","og_site_name":"softwareab","article_publisher":"https:\/\/www.facebook.com\/cloudraticsolutions\/","article_author":"https:\/\/www.facebook.com\/cloudraticsolutions\/","article_published_time":"2014-12-05T16:15:52+00:00","article_modified_time":"2014-12-05T16:18:49+00:00","author":"Andrew Bruce","twitter_card":"summary_large_image","twitter_creator":"@realcloudratics","twitter_site":"@realcloudratics","twitter_misc":{"Written by":"Andrew Bruce","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#article","isPartOf":{"@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/"},"author":{"name":"Andrew Bruce","@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600"},"headline":"Backport Websockets to Apache 2.2 (x86!)","datePublished":"2014-12-05T16:15:52+00:00","dateModified":"2014-12-05T16:18:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/"},"wordCount":402,"commentCount":0,"publisher":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600"},"keywords":["centos","sysadmin","websockets"],"articleSection":["Apache","Teknocratica"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/","url":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/","name":"Backport Websockets to Apache 2.2 (x86!) - softwareab","isPartOf":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#website"},"datePublished":"2014-12-05T16:15:52+00:00","dateModified":"2014-12-05T16:18:49+00:00","breadcrumb":{"@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.softwareab.net\/wordpress\/backport-websockets-apache-2-2-x86\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.softwareab.net\/wordpress\/"},{"@type":"ListItem","position":2,"name":"centos","item":"https:\/\/www.softwareab.net\/wordpress\/tag\/centos\/"},{"@type":"ListItem","position":3,"name":"Backport Websockets to Apache 2.2 (x86!)"}]},{"@type":"WebSite","@id":"https:\/\/www.softwareab.net\/wordpress\/#website","url":"https:\/\/www.softwareab.net\/wordpress\/","name":"softwareab","description":"Technocratica, Technopolitik, Technophobia","publisher":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.softwareab.net\/wordpress\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600","name":"Andrew Bruce","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/www.softwareab.net\/wordpress\/wp-content\/uploads\/2024\/03\/andy-cartoon.jpg","contentUrl":"https:\/\/www.softwareab.net\/wordpress\/wp-content\/uploads\/2024\/03\/andy-cartoon.jpg","width":400,"height":330,"caption":"Andrew Bruce"},"logo":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/image\/"},"description":"Team-oriented systems mentor with deep knowledge of numerous software methodologies, technologies, languages, and operating systems. Excited about turning emerging technology into working production-ready systems. Focused on moving software teams to a higher level of world-class application development. Specialties:Software analysis and development...Product management through the entire lifecycle...Discrete product integration specialist!","sameAs":["http:\/\/cloudraticsolutions.net\/","https:\/\/www.facebook.com\/cloudraticsolutions\/","https:\/\/twitter.com\/realcloudratics"]}]}},"_links":{"self":[{"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts\/910"}],"collection":[{"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/comments?post=910"}],"version-history":[{"count":5,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts\/910\/revisions"}],"predecessor-version":[{"id":915,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts\/910\/revisions\/915"}],"wp:attachment":[{"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/media?parent=910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/categories?post=910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/tags?post=910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}