Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The websockify of novnc dose not has relative path feature #1339

Closed
bhzhu203 opened this issue Dec 2, 2019 · 2 comments
Closed

The websockify of novnc dose not has relative path feature #1339

bhzhu203 opened this issue Dec 2, 2019 · 2 comments

Comments

@bhzhu203
Copy link

bhzhu203 commented Dec 2, 2019

Is your feature request related to a problem? Please describe.
When nginx has path to reverse proxy to noVNC , html/js files works fine but websocket having the wrong path . The websocket is just related to the ROOT path.

For example :

https://desktop.xxx.cn/max/vnc_lite.html
the websocket is : https://desktop.xxx.cn/websockify

I need the right path is :
https://desktop.xxx.cn/max/websockify

nginx:

location  /max/ {

     proxy_pass  http://127.0.0.1:60803/;
    #Proxy Settings
    proxy_redirect     off;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_max_temp_file_size 0;
    proxy_connect_timeout      190;
    proxy_send_timeout         190;
    proxy_read_timeout         190;
    proxy_buffer_size          32k;
    proxy_buffers              8 64k;
    proxy_busy_buffers_size    164k;
    proxy_temp_file_write_size 164k;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;

}

Describe the solution you'd like
So , I have to modify the line
1014 url += '/max/' + path; // app/ui.js
178 url += '/max' + path; //vnc_lite.html

Describe alternatives you've considered

Additional context
lALPDgQ9rSinwgXNAV7NBg0_1549_350

Is there any other way to help this automatically right? Thanks

@bhzhu203 bhzhu203 changed the title The websockify of novnc dose not have relative path feature The websockify of novnc dose not has relative path feature Dec 2, 2019
@kernelmethod
Copy link

kernelmethod commented Dec 11, 2019

I was having this same issue. I needed to have separate NoVNC servers accessible through e.g. example.com/vnc/1/, example.com/vnc/2/, etc.

I did something similar to what you've done here, except I changed the URL through UI.initSetting:

diff --git a/app/ui.js b/app/ui.js
index 7651d3e..b317636 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -167 +167,2 @@ const UI = {
-        UI.initSetting('path', 'websockify');
+        let loc = String(window.location.pathname);
+        UI.initSetting('path', loc.substring(1, loc.lastIndexOf('/')) + '/websockify');

After that, my Nginx config ended up looking close to

location ~* ^/vnc/([0-9a-zA-Z]+)/websockify$ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    resolver 127.0.0.1:53 ipv6=off;
    set $backend "http://novnc-$1:6080/websockify";
    proxy_pass $backend;
}

location ~* ^/vnc/([0-9a-zA-Z]+)/(.*) {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_buffering off;

    resolver 127.0.0.1:53 ipv6=off;
    set $backend "http://novnc-$1:6080/$2";
    proxy_pass $backend;
}

That way, if I wanted to create a new NoVNC server accessible at example.com/vnc/test/, I'd create a server with the hostname novnc-test, and then the Nginx config plus the modifications to app/ui.js would do the rest of the work for me.

@CendioOssman
Copy link
Member

I'm afraid we concluded that we cannot do this in a generic way. Please see #1058 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants