diff --git a/plugins/ui/files.go b/plugins/ui/files.go
index 9bd67d4be25af9bcfed545c7bacd8f76e9d0dab0..3d36119445ad9df550c1fe38cdee0bdf0d904491 100644
--- a/plugins/ui/files.go
+++ b/plugins/ui/files.go
@@ -494,8 +494,12 @@ Vue.component('empty-icon', {
       this.show()
       this.loggedIn = true
       this.selectedTab = 'Logs'
+      let wsProtocol = 'wss:'
+      if (location.protocol != 'https:') {
+        wsProtocol = 'ws:'
+      }
       this.ws = new WebSocket(
-        api.addToken('ws://'+window.location.host+'/ws')
+        api.addToken(wsProtocol+'//'+window.location.host+'/ws')
       )
       this.ws.onopen = (e) => { this.connected=true }
       this.ws.onclose = (e) => { this.connected=false }
diff --git a/plugins/ui/src/js/main.js b/plugins/ui/src/js/main.js
index 17f5a38827ef8d4922d40a3d6bcc4c3be4303dd5..d6266b39076b30ec5820e652d7d739176daaf616 100644
--- a/plugins/ui/src/js/main.js
+++ b/plugins/ui/src/js/main.js
@@ -34,8 +34,12 @@ new Vue({
       this.show()
       this.loggedIn = true
       this.selectedTab = 'Logs'
+      let wsProtocol = 'wss:'
+      if (location.protocol != 'https:') {
+        wsProtocol = 'ws:'
+      }
       this.ws = new WebSocket(
-        api.addToken('ws://'+window.location.host+'/ws')
+        api.addToken(wsProtocol+'//'+window.location.host+'/ws')
       )
       this.ws.onopen = (e) => { this.connected=true }
       this.ws.onclose = (e) => { this.connected=false }