[Spice-devel] [PATCH] Fix default websocket port detection in spice_auto.html

Jeremy White jwhite at codeweavers.com
Thu Aug 22 08:36:25 PDT 2013


Hi Jordan,

On 08/20/2013 12:04 PM, Jordan Pittier wrote:
> If server runs on port 80 or 443 the default value of
> window.location.port is an empty string

I'm concerned that setting port 80/443 as the default may be misleading
to the average user.

In general, the port we need to specify is going to connect to a
websockify daemon, which will relay it on to a spice server.  And, in
general, that websockify instance will need to be running on a port
*other* than 80/443, as 80/443 is usually consumed by a web server.

I realize that you may be proxying the port; I'm not very familiar with
that process.  Is this a protocol proxy?  That is, will nginx and/or
Apache intelligently relay a ws:// protocol request to an alternate port?

Cheers,

Jeremy

> 
> Signed-off-by: Jordan Pittier <jordan.pittier-ext at cloudwatt.com>
> ---
>  spice_auto.html |   14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/spice_auto.html b/spice_auto.html
> index 81ec8cf..3c853bc 100644
> --- a/spice_auto.html
> +++ b/spice_auto.html
> @@ -85,7 +85,19 @@
>  
>                  // 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);
> +                var default_port = window.location.port;
> +
> +                // if this page is served by a server listening
> +                // on port 80 or 443, default_port is an empty string
> +                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.



More information about the Spice-devel mailing list