DEV Community

Jain Wun
Jain Wun

Posted on

瀏覽器連到VNC Server


noVNC實際上也是透過Websockify連線到VNC sever

image.png

以前他們兩個是一起包在同一個GitHub repo下,後來分開維護了

但是安裝noVNC時還是會自動去裝Websockify

Insatll

如果要自行手動安裝的話

apt-get install websockify
Enter fullscreen mode Exit fullscreen mode

Usage

以前websockify和noVNC還沒分家時的用法

websockify -D \
    --web /usr/share/novnc/ \
    6080 \
    localhost:5900
Enter fullscreen mode Exit fullscreen mode

現在新版的noVNC會自己去call websockify

novnc --listen 6080 --vnc localhost:5901
Enter fullscreen mode Exit fullscreen mode

Nginx Proxy

加上reverse proxy可以讓我們直接call網址/ ip,而不用去指定6080 port

nginx.conf

user www-data;
daemon off;

events {
}

http {
  server {
    listen 80 default_server;

    location / {
      root /www/data;
      try_files $uri $uri/ /index.html;
    }

    location /novnc/ {
      proxy_pass http://127.0.0.1:6080/;
    }

    location /novnc/websockify {
      proxy_pass http://127.0.0.1:6080/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_set_header Host $host;
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Reference

Websockify & noVNC behind an NGINX Proxy

Top comments (0)