From bd27c9bca67dd4d8bf533de57da39920e126b64d Mon Sep 17 00:00:00 2001
From: Felipe Cecagno <fcecagno@gmail.com>
Date: Fri, 3 Aug 2018 17:22:34 -0300
Subject: [PATCH] put back nginx just to proxy freeswitch

---
 labs/docker/Makefile              |   1 +
 labs/docker/docker-compose.yml    |  15 ++-
 labs/docker/freeswitch/Dockerfile |   8 +-
 labs/docker/nginx/Dockerfile      |   7 --
 labs/docker/nginx/config.xml      | 158 ------------------------------
 labs/docker/nginx/nginx.conf.tmpl | 135 -------------------------
 6 files changed, 18 insertions(+), 306 deletions(-)
 delete mode 100755 labs/docker/nginx/config.xml

diff --git a/labs/docker/Makefile b/labs/docker/Makefile
index a6ff02a929..d72eb56ef3 100644
--- a/labs/docker/Makefile
+++ b/labs/docker/Makefile
@@ -52,5 +52,6 @@ release:
 	make image DIR=$(BUILD_DIR_BASE)/bbb-webhooks IMAGE_NAME=bbb-webhooks
 	make image DIR=$(BUILD_DIR_BASE)/labs/docker/kurento IMAGE_NAME=bbb-kurento
 	make image DIR=$(BUILD_DIR_BASE)/labs/docker/freeswitch IMAGE_NAME=bbb-freeswitch
+	make image DIR=$(BUILD_DIR_BASE)/labs/docker/nginx IMAGE_NAME=bbb-nginx
 	make image DIR=$(BUILD_DIR_BASE)/labs/docker/coturn IMAGE_NAME=bbb-coturn
 	make image DIR=$(BUILD_DIR_BASE)/bbb-lti IMAGE_NAME=bbb-lti
diff --git a/labs/docker/docker-compose.yml b/labs/docker/docker-compose.yml
index fabf9da3a1..be9b3cbc46 100644
--- a/labs/docker/docker-compose.yml
+++ b/labs/docker/docker-compose.yml
@@ -43,9 +43,6 @@ services:
       - coturn
     volumes:
       - media-audio:/var/freeswitch/meetings
-    labels:
-      - "traefik.backend=bbb-freeswitch"
-      - "traefik.frontend.rule=PathPrefix: /ws"
 
   bbb-webrtc-sfu:
     image: ${TAG_PREFIX}bbb-webrtc-sfu${TAG_SUFFIX}
@@ -127,6 +124,18 @@ services:
       - "traefik.backend=bbb-web"
       - "traefik.frontend.rule=PathPrefix: /bigbluebutton"
 
+  # when we're able to setup traefik properly for wss, nginx is no longer needed
+  nginx:
+    image: ${TAG_PREFIX}bbb-nginx${TAG_SUFFIX}
+    restart: unless-stopped
+    depends_on:
+      - bbb-freeswitch
+    environment:
+      SERVER_DOMAIN: ${SERVER_DOMAIN}
+    labels:
+      - "traefik.backend=bbb-freeswitch"
+      - "traefik.frontend.rule=PathPrefix: /ws"
+
   traefik:
     image: traefik
     restart: unless-stopped
diff --git a/labs/docker/freeswitch/Dockerfile b/labs/docker/freeswitch/Dockerfile
index 4e1cb76c74..86865a8fb8 100644
--- a/labs/docker/freeswitch/Dockerfile
+++ b/labs/docker/freeswitch/Dockerfile
@@ -11,12 +11,14 @@ RUN echo "deb http://ubuntu.bigbluebutton.org/xenial-200-dev bigbluebutton-xenia
  && apt-get -y install bbb-freeswitch-core \
  && find /opt/freeswitch/conf/sip_profiles/ -name "*ipv6*" -prune -exec rm -rf "{}" \;
 
-EXPOSE 8021
-EXPOSE 5060
-EXPOSE 5066
 EXPOSE 7443
 
 COPY docker-entrypoint.sh /usr/local/bin/
 COPY event_socket_conf.xml /opt/freeswitch/conf/autoload_configs/event_socket.conf.xml
 
+RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 \
+ && chmod +x /usr/local/bin/dumb-init
+
+ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
+
 CMD [ "docker-entrypoint.sh" ]
diff --git a/labs/docker/nginx/Dockerfile b/labs/docker/nginx/Dockerfile
index 5e87e99b36..56fc11c419 100644
--- a/labs/docker/nginx/Dockerfile
+++ b/labs/docker/nginx/Dockerfile
@@ -8,13 +8,6 @@ RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
   && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
 
 COPY ./nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl
-COPY ./config.xml /var/www/bigbluebutton/client/conf/config.xml
-
-RUN touch /var/log/nginx/error.log /var/log/nginx/access.log /var/log/nginx/bigbluebutton.access.log
-
-#  "-stdout", "/var/log/nginx/access.log", \
-#  "-stdout", "/var/log/nginx/bigbluebutton.access.log", \
-#  "-stderr", "/var/log/nginx/error.log", \
 
 CMD [ "dockerize", \
   "-template", "/etc/nginx/nginx.conf.tmpl:/etc/nginx/nginx.conf", \
diff --git a/labs/docker/nginx/config.xml b/labs/docker/nginx/config.xml
deleted file mode 100755
index 084f76ef1b..0000000000
--- a/labs/docker/nginx/config.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" ?>
-<config>
-    <localeversion suppressWarning="false">0.9.0</localeversion>
-    <version>VERSION</version>
-    <help url="http://HOST/help.html"/>
-    <javaTest url="http://HOST/testjava.html"/>
-    <porttest host="rtmp://HOST" application="video/portTest" timeout="10000"/>
-    <bwMon server="rtmp://HOST" application="video/bwTest"/>
-    <application uri="rtmp://HOST/bigbluebutton" host="http://HOST/bigbluebutton/api/enter"/>
-    <language userSelectionEnabled="true" rtlEnabled="false"/>
-    <skinning url="http://HOST/client/branding/css/V2Theme.css.swf?v=VERSION" />
-    <branding logo="logos/logo.swf" copyright="&#169; 2017 &lt;u&gt;&lt;a href=&quot;http://HOST/home.html&quot; target=&quot;_blank&quot;&gt;BigBlueButton Inc.&lt;/a&gt;&lt;/u&gt; (build {0})" background="" toolbarColor="" showQuote="true"/>
-    <shortcutKeys showButton="true" />
-    <browserVersions chrome="CHROME_VERSION" firefox="FIREFOX_VERSION" flash="FLASH_VERSION"/>
-    <layout showLogButton="false" defaultLayout="bbb.layout.name.defaultlayout"
-            showToolbar="true" showFooter="true" showMeetingName="true" showHelpButton="true"
-            showLogoutWindow="true" showLayoutTools="true" confirmLogout="true" showNetworkMonitor="false"
-            showRecordingNotification="true" logoutOnStopRecording="false"
-            askForFeedbackOnLogout="false"/>
-    <breakoutRooms enabled="true" record="false" privateChateEnabled="true"/>
-    <logging enabled="true" logTarget="trace" level="info" format="{dateUTC} {time} :: {name} :: [{logLevel}] {message}" uri="http://HOST/log" logPattern=".*"/>
-    <lock disableCam="false" disableMic="false" disablePrivateChat="false"
-          disablePublicChat="false" lockedLayout="false" lockOnJoin="true" lockOnJoinConfigurable="false"/>
-
-		<modules>
-
-		<module name="ChatModule" url="http://HOST/client/ChatModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			dependsOn="UsersModule"	
-			privateEnabled="true"  
-			fontSize="14"
-			baseTabIndex="801"
-			colorPickerIsVisible="false"
-			maxMessageLength="1024"
-		/>
-
-		<module name="UsersModule" url="http://HOST/client/UsersModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			allowKickUser="true"
-			enableEmojiStatus="true"
-			enableSettingsButton="true"
-			enableGuestUI="false"
-			moderatorUnmute="true"
-			baseTabIndex="301"
-		/>
-
-		<module name="ScreenshareModule"
-			url="http://HOST/client/ScreenshareModule.swf?v=VERSION"
-			uri="rtmp://HOST/screenshare"
-			showButton="true"
-			enablePause="true"
-			tryKurentoWebRTC="false"
-			tryWebRTCFirst="false"
-			chromeExtensionLink=""
-			chromeExtensionKey=""
-			baseTabIndex="201"
-			help="http://HOST/client/help/screenshare-help.html"
-		/>
-
-		<module name="PhoneModule" url="http://HOST/client/PhoneModule.swf?v=VERSION"
-			uri="rtmp://HOST/sip" 
-			dependsOn="UsersModule"
-			autoJoin="true"
-			listenOnlyMode="true"
-			forceListenOnly="false"
-			skipCheck="false"
-			showButton="true"
-			enabledEchoCancel="true"
-			useWebRTCIfAvailable="true"
-			showPhoneOption="false"
-			showWebRTCStats="false"
-			showWebRTCMOS="false"
-			echoTestApp="9196"
-		/>
-
-		<module name="VideoconfModule" url="http://HOST/client/VideoconfModule.swf?v=VERSION"
-			uri="rtmp://HOST/video"
-			dependsOn="UsersModule"
-			baseTabIndex="401"
-			autoStart="false"
-			skipCamSettingsCheck="false"
-			showButton="true"
-			applyConvolutionFilter="false"
-			convolutionFilter="-1, 0, -1, 0, 6, 0, -1, 0, -1"
-			filterBias="0"
-			filterDivisor="4"
-			displayAvatar="false"
-			priorityRatio="0.67"
-		/>
-
-		<module name="WhiteboardModule" url="http://HOST/client/WhiteboardModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			dependsOn="PresentModule"
-			baseTabIndex="601"
-			keepToolbarVisible="false"
-		/>
-
-		<module name="PollingModule" url="http://HOST/client/PollingModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			dependsOn="PresentModule"
-		/>
-
-		<module name="PresentModule" url="http://HOST/client/PresentModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			dependsOn="UsersModule"
-			host="http://HOST" 
-			showPresentWindow="true"
-			showWindowControls="true"
-			openExternalFileUploadDialog="false"
-			baseTabIndex="501"
-			maxFileSize="30"
-			enableDownload="true"
-		/>
-
-		<module name="CaptionModule" url="http://HOST/client/CaptionModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton" 
-			dependsOn="UsersModule"
-			maxPasteLength="1024"
-			baseTabIndex="701"
-		/>
-
-		<module name="LayoutModule" url="http://HOST/client/LayoutModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton"
-			layoutConfig="http://HOST/client/conf/layout.xml"
-			enableEdit="false"
-		/>
-
-		<module name="SharedNotesModule" url="http://HOST/client/SharedNotesModule.swf?v=VERSION"
-			uri="rtmp://HOST/bigbluebutton"
-			dependsOn="UsersModule"
-			refreshDelay="500"
-			toolbarVisibleByDefault="false"
-			showToolbarButton="true"
-			fontSize="14"
-			maxMessageLength="5000"
-			maxNoteLength="10000"
-			enableDeleteNotes="false"
-			hideAdditionalNotes="false"
-		/>
-
-<!--
-    <module name="NotesModule" url="http://HOST/client/NotesModule.swf?v=VERSION"
-      saveURL="http://HOST"
-      position="top-left"
-    />
-    
-    <module name="BroadcastModule" url="http://HOST/client/BroadcastModule.swf?v=VERSION"
-      uri="rtmp://HOST/bigbluebutton"
-      streamsUri="http://HOST/streams.xml"
-      position="top-left"
-      showStreams="true"
-      autoPlay="false"
-      dependsOn="UsersModule"
-    />
--->
-
-	</modules>
-</config>
diff --git a/labs/docker/nginx/nginx.conf.tmpl b/labs/docker/nginx/nginx.conf.tmpl
index 590e2d93d6..0210fc399b 100644
--- a/labs/docker/nginx/nginx.conf.tmpl
+++ b/labs/docker/nginx/nginx.conf.tmpl
@@ -49,52 +49,9 @@ http {
         listen   80;
         listen [::]:80;
         server_name {{ .Env.SERVER_DOMAIN }};
-        listen 443 ssl;
-        listen [::]:443 ssl;
-        ssl_certificate {{ .Env.SSL_CERT_PATH }};
-        ssl_certificate_key {{ .Env.SSL_KEY_PATH }};
-        ssl_session_cache shared:SSL:10m;
-        ssl_session_timeout 10m;
-        # need TLSv1 for the Java calls for the API, otherwise it would be removed
-        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
-        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
-        ssl_prefer_server_ciphers on;
-        ssl_dhparam {{ .Env.SSL_DHPARAM_PATH }};
-        ssl_ecdh_curve secp384r1;
-        ssl_session_tickets off;
-        ssl_stapling on;
-        ssl_stapling_verify on;
-        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
 
         access_log  /var/log/nginx/bigbluebutton.access.log;
 
-        # BigBlueButton landing page.
-        location / {
-            root   /var/www/bigbluebutton-default;
-            index  index.html index.htm;
-            expires 1m;
-        }
-
-        # BigBlueButton Flash client.
-        location /client {
-            root    /var/www/bigbluebutton;
-            index  index.html index.htm;
-        }
-
-        location /playback/presentation/playback.html {
-            return 301 /playback/presentation/0.81/playback.html?$query_string;
-        }
-
-        location /playback/presentation {
-            root    /var/bigbluebutton;
-            index  index.html index.htm;
-        }
-
-        location /presentation {
-            root    /var/bigbluebutton/published;
-            index  index.html index.htm;
-        }
-
         location /ws {
             proxy_pass https://bbb-freeswitch:7443;
             proxy_http_version 1.1;
@@ -105,97 +62,5 @@ http {
             client_body_timeout 6h;
             send_timeout 6h;
         }
-
-        # Pass to the webhooks app all requests made to the webhooks API.
-        location /bigbluebutton/api/hooks {
-            proxy_pass     http://bbb-webhooks:3005;
-            proxy_redirect     default;
-            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
-            proxy_set_header   X-Real-IP     $remote_addr;
-            proxy_set_header   Host      $http_host;
-            proxy_set_header   X-NginX-Proxy     true;
-        }
-
-        # Handle request to bbb-web running within Tomcat.  This is for
-        # the BBB-API and Presentation.
-        location /bigbluebutton {
-            proxy_pass     http://bbb-web:8080;
-            proxy_redirect     default;
-            proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
-
-            # Workaround IE refusal to set cookies in iframe
-            add_header P3P 'CP="No P3P policy available"';
-
-            # Allow 30M uploaded presentation document.
-            client_max_body_size       30m;
-            client_body_buffer_size    128k;
-
-            proxy_connect_timeout      90;
-            proxy_send_timeout     90;
-            proxy_read_timeout     90;
-
-            proxy_buffer_size      4k;
-            proxy_buffers      4 32k;
-            proxy_busy_buffers_size    64k;
-            proxy_temp_file_write_size 64k;
-
-            include    fastcgi_params;
-        }
-
-        location /bbb-webrtc-sfu {
-            proxy_pass http://bbb-webrtc-sfu:3008;
-            proxy_http_version 1.1;
-            proxy_set_header Upgrade $http_upgrade;
-            proxy_set_header Connection "Upgrade";
-            proxy_read_timeout 6h;
-            proxy_send_timeout 6h;
-            client_body_timeout 6h;
-            send_timeout 6h;
-        }
-
-        location /html5client {
-            proxy_pass http://bbb-html5:3000;
-            proxy_http_version 1.1;
-            proxy_set_header Upgrade $http_upgrade;
-            proxy_set_header Connection "Upgrade";
-        }
-
-        location /_timesync {
-            proxy_pass http://bbb-html5:3000;
-        }
-
-#        # Routes requests to Greenlight based on the '/b' prefix
-#        location /b {
-#            proxy_pass          http://greenlight:80;
-#            proxy_set_header    Host              $host;
-#            proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
-#            proxy_set_header    X-Forwarded-Proto $scheme;
-#            proxy_http_version  1.1;
-#        }
-#
-#        location /b/cable {
-#            proxy_pass          http://greenlight:80;
-#            proxy_set_header    Host              $host;
-#            proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
-#            proxy_set_header    X-Forwarded-Proto $scheme;
-#            proxy_set_header    Upgrade           $http_upgrade;
-#            proxy_set_header    Connection        "Upgrade";
-#            proxy_http_version  1.1;
-#            proxy_read_timeout  6h;
-#            proxy_send_timeout  6h;
-#            client_body_timeout 6h;
-#            send_timeout        6h;
-#        }
-
-        # Redirect server error pages to the static page /50x.html
-        #
-        error_page   500 502 503 504  /50x.html;
-        location = /50x.html {
-               root   /var/www/nginx-default;
-        }
-
-        location = / {
-            return 301 /b;
-        }
     }
 }
-- 
GitLab