diff --git a/config/trackdirect.ini b/config/trackdirect.ini
index af33eed136a0f13b80c2cd1777881a40f7c794aa..fa4ee977cc81657eed7f779f7955e354b3b0cbe9 100644
--- a/config/trackdirect.ini
+++ b/config/trackdirect.ini
@@ -23,6 +23,10 @@ leaflet_raster_tile_satellite=""            ;; Examples: "HERE.satelliteDay"
 coverage_only_moving_senders="0"
 coverage_percentile="95"
 
+;; Url to the websocket server, if you use https you need to set this
+;; If nothing is set we will try the url: ws://current-url:9000/ws
+;websocket_url="wss://ws.my-domain.com"
+
 
 [database]
 
diff --git a/htdocs/public/index.php b/htdocs/public/index.php
index c26188b6f17f8bb2ae6eb49fe32539f8683be695..9cefff19e7cf6932b2c148d4df68cbf467893aa7 100755
--- a/htdocs/public/index.php
+++ b/htdocs/public/index.php
@@ -146,9 +146,9 @@ $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
                     options['host'] = "<?php echo $_SERVER['HTTP_HOST']; ?>";
 
                     var supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window;
-                    if (supportsWebSockets) {
-                        <?php if ($REQUEST_PROTOCOL == 'https') : ?>
-                            var wsServerUrl = 'wss://<?php echo $_SERVER['HTTP_HOST']; ?>:9000/ws';
+		    if (supportsWebSockets) {
+                       <?php if (getWebsiteConfig('websocket_url') != null) : ?>
+                           var wsServerUrl = "<?php echo getWebsiteConfig('websocket_url'); ?>";
                         <?php else : ?>
                             var wsServerUrl = 'ws://<?php echo $_SERVER['HTTP_HOST']; ?>:9000/ws';
                         <?php endif; ?>