{"id":906,"date":"2014-12-03T13:33:38","date_gmt":"2014-12-03T18:33:38","guid":{"rendered":"https:\/\/www.softwareab.net\/wordpress\/?p=906"},"modified":"2014-12-03T13:45:41","modified_gmt":"2014-12-03T18:45:41","slug":"websockets-centos-6-apache-2-4","status":"publish","type":"post","link":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/","title":{"rendered":"Websockets, CentOS 6, and Apache 2.4"},"content":{"rendered":"<p>Problem: Apache 2.2 does not support websockets. This precludes using it as reverse proxy for NoVNC, and also for RShiny apps. This is a problem for us because we require access to Shiny apps over our standard Apache proxy. Read on for our solution!<\/p>\n<p><!--more--><\/p>\n<p>Approach: Solve the problem using standard CentOS image with Apache 2.4 (which supports websockets). Prove we have a solution on a standalone VM, then we&#8217;ll migrate our existing Apache proxy.<\/p>\n<p>Procedure:<\/p>\n<ol>\n<li>Create \/ basic configure the Guest VM within your virtualization environment (we use OpenStack). Launch a new instance based on vanilla CentOS VM instance, reboot at first login to force hostname to set completely, perform a <code>yum update<\/code>).<\/li>\n<li>Setup <code>iptables<\/code>:\n<pre><code>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<\/code><\/pre>\n<p>Be sure to add the HTTP\/HTTPS ports for your VM Security Group if running virtually. Then reload the firewall:<\/p>\n<pre><code>service iptables reload<\/code><\/pre>\n<\/li>\n<li>Install Apache 2.4 for CentOS (no base support in CentOS <code>yum<\/code> repository):\n<pre><code>cd \/etc\/yum.repos.d\r\nwget <a href=\"http:\/\/repos.fedorapeople.org\/repos\/jkaluza\/httpd24\/epel-httpd24.repo\">http:\/\/repos.fedorapeople.org\/repos\/jkaluza\/httpd24\/epel-httpd24.repo<\/a><\/code><\/pre>\n<p>Install the software and verify the version (note the explicit package names and non-standard location for installed binary):<\/p>\n<pre><code>yum install httpd24.x86_64\r\n\/opt\/rh\/httpd24\/root\/usr\/sbin\/httpd -version<\/code><\/pre>\n<p>Set software to start automatically (note service name):<\/p>\n<pre><code>chkconfig httpd24-httpd on\r\nservice httpd24-httpd start<\/code><\/pre>\n<\/li>\n<li>Setup SSL. We\u2019ll install the module, then disable the default SSL Web site since we\u2019ll use our own for our test. This directly emulates what we do in production.<br \/>\nFirst, install the module:<\/p>\n<pre><code>yum install httpd24-mod_ssl.x86_64<\/code><\/pre>\n<p>Then comment out the default SSL Web site:<\/p>\n<pre><code>\r\n# \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/ssl.conf\r\n<em>[...comment out lines from...]<\/em>\r\n&lt;VirtualHost _default_:443&gt;\r\n<em>[...all the way to...]<\/em>\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<\/li>\n<li>Setup system to emulate \u201cstandard\u201d Apache file locations (remember that installing the special 2.4 Apache will <strong>not<\/strong> create these locations). This allows us to setup our configuration file exactly as we will use it in production:\n<pre><code>mkdir -p \/etc\/httpd \/var\/log\/httpd\r\nchmod 700 \/var\/log\/httpd<\/code><\/pre>\n<\/li>\n<li>Create the configuration file:\n<pre><code>cd \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d<\/code><\/pre>\n<p>Set the configuration file contents:<\/p>\n<pre><code>\r\n# \/opt\/rh\/httpd24\/root\/etc\/httpd\/conf.d\/wstunnel-test.conf\r\nLoadModule proxy_wstunnel_module modules\/mod_proxy_wstunnel.so\r\n\r\n&lt;VirtualHost *:80&gt;\r\n  LogLevel debug\r\n  ServerName shiny-demo.hlsdev.com\r\n  RewriteEngine On\r\n  RewriteRule (.*) https:\/\/shiny-demo.hlsdev.com\/%{REQUEST_URI}\r\n  CustomLog \/var\/log\/httpd\/demo.log combined\r\n  ErrorLog \/var\/log\/httpd\/demo_error.log\r\n&lt;\/VirtualHost&gt;\r\n&lt;VirtualHost *:443&gt;\r\n  LogLevel debug\r\n  ServerName shiny-demo.example.com\r\n  SSLEngine ON\r\n  SSLCertificateFile \/etc\/httpd\/example.com.crt\r\n  SSLCertificateKeyFile \/etc\/httpd\/example.com.key\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:\/\/mybackend.example.local:3838\/$1\r\n\r\n  ProxyPass \/ http:\/\/mybackend.example.local:3838\/ max=1 disablereuse=on keepalive=on\r\n  ProxyPassReverse \/ http:\/\/mybackend.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 <code>ProxyPassMatch<\/code> command. The regular expression checks for <code>__socksjs__<\/code> followed by an all-numeric identifier. If found, then the proxy will send the request to the <code>ws:\/\/<\/code> destination, which automagically invokes the ws_tunnel code.<\/li>\n<li>Restart your web server:\n<pre><code>service httpd24-httpd restart<\/code><\/pre>\n<\/li>\n<li>Test your websocketized application. Notice that we enabled <code>LogLevel debug<\/code> above so we can see the Websockets tunnel at work in the error log file:\n<pre><code>\r\n[Wed Dec 03 12:17:15.558370 2014] [proxy_wstunnel:debug] [pid 2042] mod_proxy_wstunnel.c(331): [client 172.20.128.2:62126] AH02451: serving URL ws:\/\/mybackend.example.local:3838\/sample-apps\/rmd\/__sockjs__\/510\/w2kfd1y0\/websocket\r\n<\/code><\/pre>\n<p>In the above snippet, the Websockets tunnel code kicked in, detected the sockets pattern we defined in the <code>ProxyPassMatch<\/code> and served the file to the Websockets backend server. Kewl!\n<\/li>\n<\/ol>\n<p>That is all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Apache 2.2 does not support websockets. This precludes using it as reverse proxy for NoVNC, and also for RShiny apps. This is a problem for us because we require access to Shiny apps over our standard Apache proxy. Read &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\"> <span class=\"screen-reader-text\">Websockets, CentOS 6, and Apache 2.4<\/span> Read More &raquo;<\/a><\/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":[78,42,79],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Websockets, CentOS 6, and Apache 2.4 - 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\/websockets-centos-6-apache-2-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Websockets, CentOS 6, and Apache 2.4 - softwareab\" \/>\n<meta property=\"og:description\" content=\"Problem: Apache 2.2 does not support websockets. This precludes using it as reverse proxy for NoVNC, and also for RShiny apps. This is a problem for us because we require access to Shiny apps over our standard Apache proxy. Read &hellip; Websockets, CentOS 6, and Apache 2.4 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\" \/>\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-03T18:33:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-12-03T18:45:41+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\"},\"author\":{\"name\":\"Andrew Bruce\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\"},\"headline\":\"Websockets, CentOS 6, and Apache 2.4\",\"datePublished\":\"2014-12-03T18:33:38+00:00\",\"dateModified\":\"2014-12-03T18:45:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\"},\"wordCount\":384,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600\"},\"keywords\":[\"apache\",\"centos\",\"websockets\"],\"articleSection\":[\"Apache\",\"Teknocratica\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\",\"url\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\",\"name\":\"Websockets, CentOS 6, and Apache 2.4 - softwareab\",\"isPartOf\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/#website\"},\"datePublished\":\"2014-12-03T18:33:38+00:00\",\"dateModified\":\"2014-12-03T18:45:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.softwareab.net\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"apache\",\"item\":\"https:\/\/www.softwareab.net\/wordpress\/tag\/apache-2\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Websockets, CentOS 6, and Apache 2.4\"}]},{\"@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":"Websockets, CentOS 6, and Apache 2.4 - 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\/websockets-centos-6-apache-2-4\/","og_locale":"en_US","og_type":"article","og_title":"Websockets, CentOS 6, and Apache 2.4 - softwareab","og_description":"Problem: Apache 2.2 does not support websockets. This precludes using it as reverse proxy for NoVNC, and also for RShiny apps. This is a problem for us because we require access to Shiny apps over our standard Apache proxy. Read &hellip; Websockets, CentOS 6, and Apache 2.4 Read More &raquo;","og_url":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/","og_site_name":"softwareab","article_publisher":"https:\/\/www.facebook.com\/cloudraticsolutions\/","article_author":"https:\/\/www.facebook.com\/cloudraticsolutions\/","article_published_time":"2014-12-03T18:33:38+00:00","article_modified_time":"2014-12-03T18:45:41+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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#article","isPartOf":{"@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/"},"author":{"name":"Andrew Bruce","@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600"},"headline":"Websockets, CentOS 6, and Apache 2.4","datePublished":"2014-12-03T18:33:38+00:00","dateModified":"2014-12-03T18:45:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/"},"wordCount":384,"commentCount":2,"publisher":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#\/schema\/person\/1337443eaeb75104e0410b508e67f600"},"keywords":["apache","centos","websockets"],"articleSection":["Apache","Teknocratica"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/","url":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/","name":"Websockets, CentOS 6, and Apache 2.4 - softwareab","isPartOf":{"@id":"https:\/\/www.softwareab.net\/wordpress\/#website"},"datePublished":"2014-12-03T18:33:38+00:00","dateModified":"2014-12-03T18:45:41+00:00","breadcrumb":{"@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.softwareab.net\/wordpress\/websockets-centos-6-apache-2-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.softwareab.net\/wordpress\/"},{"@type":"ListItem","position":2,"name":"apache","item":"https:\/\/www.softwareab.net\/wordpress\/tag\/apache-2\/"},{"@type":"ListItem","position":3,"name":"Websockets, CentOS 6, and Apache 2.4"}]},{"@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\/906"}],"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=906"}],"version-history":[{"count":3,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts\/906\/revisions"}],"predecessor-version":[{"id":909,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/posts\/906\/revisions\/909"}],"wp:attachment":[{"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/media?parent=906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/categories?post=906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwareab.net\/wordpress\/wp-json\/wp\/v2\/tags?post=906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}