[Kimchi-devel] [PATCH] [Kimchi] Change VNC & Spice console URLs to reference web interface port

Galen Pospisil galen.m.pospisil at gmail.com
Wed Jul 12 19:53:10 UTC 2017


This change allows the user to place a reverse proxy in front of
kimchi's built-in nginx proxy. The user-added reverse proxy can then
handle translation to the port exposed by kimchi/nginx.
Specifically, this patch uses the javascript location object to get
the current port and protocol used to connect to kimchi/wok.
Without this change, kimchi/wok serves up the wrong url (and port)
for the noVNC and Spice consoles when behind a reverse proxy.
---
 ui/js/src/kimchi.api.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 618d68b..0cacab3 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -337,7 +337,7 @@ var kimchi = {
     },
 
     vncToVM : function(vm) {
-        proxy_port = wok.config['proxy_port'];
+        proxy_port = location.port || (location.protocol === 'https:' ? '443' : '80');
         server_root = wok.config['server_root'];
         wok.requestJSON({
             url : "plugins/kimchi/vms/" + encodeURIComponent(vm) + "/connect",
@@ -363,7 +363,7 @@ var kimchi = {
     },
 
     spiceToVM : function(vm) {
-        proxy_port = wok.config['proxy_port'];
+        proxy_port = location.port || (location.protocol === 'https:' ? '443' : '80');
         server_root = wok.config['server_root'];
         wok.requestJSON({
             url : "plugins/kimchi/vms/" + encodeURIComponent(vm) + "/connect",
-- 
2.7.4



More information about the Kimchi-devel mailing list