Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


vnc ubuntu

07 Jun 2022 »

https://datawookie.dev/blog/2021/08/websockify-novnc-behind-an-nginx-proxy/

apt install -y xvfb novnc x11vnc websockify fluxbox firefox nginx

1 Create Screen

Xvfb :1 -screen 0, 1024x720x24
screen -dmS xvfb bash -c "Xvfb :1 -screen 0, 1024x720x24"

2 Display to rfbport

x11vnc -display :1 -noxdamage -rfbport 4900
screen -dmS x11 bash -c "x11vnc -display :1 -noxdamage -rfbport 4900"

Setup websockify

screen -dmS novnc bash -c "novnc_server --listen 7900 --vnc localhost:4900"

Setup nginx -> websockify

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;
    }
  }
}

Start fluxbox

DISPLAY=:1 fluxbox

Start GUI

DISPLAY=:1 gnome-disks
DISPLAY=:1 firefox
DISPLAY=:1 jmeter.sh

apps

screen -dmS firefox bash -c "DISPLAY=:1 firefox"
screen -dmS xclock bash -c "DISPLAY=:1 xclock"
screen -dmS xeyes bash -c "DISPLAY=:1 xeyes"
screen -dmS gnome-disks bash -c "DISPLAY=:1 gnome-disks"
screen -dmS fluxbox bash -c "DISPLAY=:1 fluxbox"
websockify -D \
    --web /usr/share/novnc/ \
    6080 \
    localhost:4900