From b0509ca4495928b267defcca016de18021a36436 Mon Sep 17 00:00:00 2001 From: Jordan Pittier Date: Tue, 20 Aug 2013 19:04:36 +0200 Subject: Fix default websocket port detection in spice_auto.html If server runs on port 80 or 443 the default value of window.location.port is an empty string Signed-off-by: Jordan Pittier --- spice_auto.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spice_auto.html b/spice_auto.html index 81ec8cf..0a01996 100644 --- a/spice_auto.html +++ b/spice_auto.html @@ -85,7 +85,20 @@ // By default, use the host and port of server that served this file host = spice_query_var('host', window.location.hostname); - port = spice_query_var('port', window.location.port); + + // Note that using the web server port only makes sense + // if your web server has a reverse proxy to relay the WebSocket + // traffic to the correct destination port. + var default_port = window.location.port; + if (!default_port) { + if (window.location.protocol == 'http:') { + default_port = 80; + } + else if (window.location.protocol == 'https:') { + default_port = 443; + } + } + port = spice_query_var('port', default_port); // If a token variable is passed in, set the parameter in a cookie. // This is used by nova-spiceproxy. -- cgit v1.2.3