From a72f70887427c171929581c9af6595bc9c9900d8 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 27 Jul 2017 17:46:24 +0200 Subject: [PATCH] Support Socket.IO websocket proxying --- .../httpd/conf/httpd.conf/20LoadModule98ExtraMod | 6 ++++++ .../conf/httpd.conf/WebAppVirtualHost/50Content | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule98ExtraMod b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule98ExtraMod index 8c2337c..6eabcf9 100644 --- a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule98ExtraMod +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/20LoadModule98ExtraMod @@ -12,4 +12,10 @@ if ( -e '/usr/lib64/httpd/modules/mod_authnz_ldap.so' || $OUT .= "LoadModule authnz_ldap_module modules/mod_authnz_ldap.so\n"; } +# Load wstunnel if available +if ( -e '/usr/lib64/httpd/modules/mod_proxy_wstunnel.so' || + -e '/usr/lib/httpd/modules/mod_proxy_wstunnel.so'){ + $OUT .= "LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so\n"; +} + } diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content index b921cee..8df672b 100644 --- a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content @@ -19,6 +19,7 @@ my $auth = $domain->prop('Authentication') || 'none'; my @groups = split(/[;,]/, ($domain->prop('AllowGroups') || '')); my $ssl_port = $modSSL{'TCPPort'} || '443'; my $proto = ($port eq $ssl_port ) ? 'https' : 'http'; +my $socketio = $domain->prop('ProxySocketIO') || 'disabled'; # ProxyPass ? if ($target =~ m|https?://[\d\w\.\-/]*|){ @@ -31,6 +32,26 @@ if ($target =~ m|https?://[\d\w\.\-/]*|){ if ($proxy_acme eq 'disabled'){ $OUT .= " ProxyPass /.well-known/acme-challenge/ !\n"; } + if ($socketio eq 'enabled'){ + # Try to handle Socket.IO + my $wstarget = $target; + $wstarget =~ s/^http:/ws:/; + $wstarget =~ s/^https:/wss:/; + $OUT .=<<"_EOF" + + + RewriteCond %{QUERY_STRING} transport=polling [NC] + RewriteRule /socket.io/(.*) ${target}socket.io/\$1 [P,L] + + ProxyPass /socket.io/socket.io.js ${target}socket.io/socket.io.js + ProxyPassReverse /socket.io/socket.io.js ${target}socket.io/socket.io.js + + ProxyPass /socket.io/ ${wstarget}socket.io/ + ProxyPassReverse /socket.io/ ${wstarget}socket.io/ + + +_EOF + } $OUT .= " ProxyPass / $target\n"; $OUT .= " ProxyPassReverse / $target\n"; }