From cb00ca07c897b5a725b918e434dc654511552154 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 18 Apr 2025 16:44:46 +0000 Subject: [PATCH 1/2] KASM-7202 run web code from source using node --- BUILDING.txt | 33 +++++++++++++++++++++++ CMakeLists.txt | 2 +- builder/build.sh | 15 ++++++----- builder/conf/nginx_kasm.conf | 42 +++++++++++++++++++++++++++++ builder/dockerfile.ubuntu_jammy.dev | 9 +++++-- 5 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 builder/conf/nginx_kasm.conf diff --git a/BUILDING.txt b/BUILDING.txt index 4bfaa3f..21c33f6 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -105,6 +105,39 @@ Now run Xvnc and Xfce4 from inside the container Now open a browser and navigate to your dev VM on port 6901. +Running noVNC from source +------------------------- +If you need to debug or make changes to the UI code, use the following procedures to use npm to serve the web code. The code will automatically rebuild when changes are made and the code will not be packaged. +These steps assume you have already built the docker image covered in the previous section named `kasmvnc:dev`. + +```bash +# run an instance of the dev container, expose an additional port +sudo docker run -it -v ./:/src -p 6901:6901 -p 8443:8443 --name kasmvnc_dev kasmvnc:dev +``` + +Now from inside the container. **This assumes KasmVNC is already built, follow steps above if you need to build KasmVNC** + +```bash +# Run KasmVNC +/src/xorg.build/bin/Xvnc -interface 0.0.0.0 -PublicIP 127.0.0.1 -disableBasicAuth -RectThreads 0 -Log *:stdout:100 -httpd /src/kasmweb/dist -sslOnly 0 -SecurityTypes None -websocketPort 6901 :1 & +/usr/bin/xfce4-session --display :1 & + +sudo nginx +cd kasmweb +npm install +npm run serve # <-- Needs to run in foreground +``` + +Now open a browser and navigate to your dev VM on port 8443 over https. + +NGINX is proxying the websocket to KasmVNC and all other requests go to the node server. NGINX listens on 8443 with ssl. + +Since `npm run serve` needs to run in the foreground, you may need to exec into the container from another terminal to run additional commands like stopping Xvnc, rebuilding KasmVNC, etc. + +```bash +sudo docker exec -it kasmvnc_dev /bin/bash +``` + Building the KasmVNC Server on Modern Unix/Linux Systems --------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 22f21dc..2276b74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,7 +242,7 @@ if(ENABLE_NLS) add_subdirectory(po) endif() -####add_subdirectory(tests) +#############add_subdirectory(tests) include(cmake/BuildPackages.cmake) diff --git a/builder/build.sh b/builder/build.sh index be9d899..2957e64 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -119,24 +119,25 @@ make -j5 # modifications for the servertarball cd /src mkdir -p xorg.build/bin +mkdir -p xorg.build/lib cd xorg.build/bin/ -ln -s /src/unix/xserver/hw/vnc/Xvnc Xvnc +ln -sf /src/unix/xserver/hw/vnc/Xvnc Xvnc cd .. mkdir -p man/man1 touch man/man1/Xserver.1 cp /src/unix/xserver/hw/vnc/Xvnc.man man/man1/Xvnc.1 -mkdir lib + cd lib if [ -d /usr/lib/x86_64-linux-gnu/dri ]; then - ln -s /usr/lib/x86_64-linux-gnu/dri dri + ln -sfn /usr/lib/x86_64-linux-gnu/dri dri elif [ -d /usr/lib/aarch64-linux-gnu/dri ]; then - ln -s /usr/lib/aarch64-linux-gnu/dri dri + ln -sfn /usr/lib/aarch64-linux-gnu/dri dri elif [ -d /usr/lib/arm-linux-gnueabihf/dri ]; then - ln -s /usr/lib/arm-linux-gnueabihf/dri dri + ln -sfn /usr/lib/arm-linux-gnueabihf/dri dri elif [ -d /usr/lib/xorg/modules/dri ]; then - ln -s /usr/lib/xorg/modules/dri dri + ln -sfn /usr/lib/xorg/modules/dri dri else - ln -s /usr/lib64/dri dri + ln -sfn /usr/lib64/dri dri fi cd /src diff --git a/builder/conf/nginx_kasm.conf b/builder/conf/nginx_kasm.conf new file mode 100644 index 0000000..a341c59 --- /dev/null +++ b/builder/conf/nginx_kasm.conf @@ -0,0 +1,42 @@ +server { + listen 8443 ssl; + ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; + ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + + location / { + proxy_pass http://127.0.0.1:5173; + } + + location /api/ { + proxy_pass https://127.0.0.1:6901; + } + + location /websockify { + # The following configurations must be configured when proxying to Kasm Workspaces + + # WebSocket Support + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # Host and X headers + 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_set_header X-Forwarded-Proto $scheme; + + # Connectivity Options + proxy_http_version 1.1; + proxy_read_timeout 1800s; + proxy_send_timeout 1800s; + proxy_connect_timeout 1800s; + proxy_buffering off; + + # Allow large requests to support file uploads to sessions + client_max_body_size 10M; + + # # Proxy to KasmVNC using SSL + #proxy_pass https://127.0.0.1:6901; + # Proxy to KasmVNC without SSL + proxy_pass http://127.0.0.1:6901; + } + } \ No newline at end of file diff --git a/builder/dockerfile.ubuntu_jammy.dev b/builder/dockerfile.ubuntu_jammy.dev index d13638d..803e2a6 100644 --- a/builder/dockerfile.ubuntu_jammy.dev +++ b/builder/dockerfile.ubuntu_jammy.dev @@ -10,13 +10,18 @@ EXPOSE 6901 USER root +COPY builder/conf/nginx_kasm.conf /etc/nginx/conf.d/ + RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list && \ apt update && \ - apt install -y socat sudo libxfont-dev cmake git libgnutls28-dev vim wget tightvncserver curl libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev pkg-config libfreetype6-dev libxtst-dev autoconf automake libtool xutils-dev libpixman-1-dev libxshmfence-dev libxcvt-dev libxkbfile-dev x11proto-dev libgbm-dev inotify-tools && \ + apt install -y socat vim wget tightvncserver curl inotify-tools sudo \ + libxfont-dev libgnutls28-dev libpng-dev libtiff-dev libgif-dev libavcodec-dev libssl-dev libxrandr-dev libxcursor-dev pkg-config libfreetype6-dev \ + libxtst-dev xutils-dev libpixman-1-dev libxshmfence-dev libxcvt-dev libxkbfile-dev x11proto-dev libgbm-dev \ + cmake git autoconf automake libtool && \ echo "kasm-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - -RUN apt install -y nodejs +RUN apt install -y nodejs nginx USER 1000 From f13a4c198c263e1cd53e685e50f774d1977ebea3 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 3 May 2025 10:44:36 +0000 Subject: [PATCH 2/2] clarify readme --- BUILDING.txt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index 34c6cdf..4cd1a8e 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -78,7 +78,7 @@ Building the KasmVNC Server using Docker git submodule init git submodule update --remote --merge sudo docker build -t kasmvnc:dev -f builder/dockerfile.ubuntu_jammy.dev . -sudo docker run -it -v ./:/src -p 6901:6901 kasmvnc:dev +sudo docker run -it --rm -v ./:/src -p 6901:6901 -p 8443:8443 --name kasmvnc_dev kasmvnc:dev ``` Now from inside the container. @@ -89,9 +89,9 @@ cd kasmweb npm install npm run build # <-- only run this on subsequent changes to front-end code cd .. -# build dependencies -sudo builder/scripts/build-webp -sudo builder/scripts/build-libjpeg-turbo +# build dependencies, this is optional as they are pre-built in the docker image. Only rebuild if you made version changes and need to test. +# sudo builder/scripts/build-webp +# sudo builder/scripts/build-libjpeg-turbo # Build KasmVNC builder/build.sh ``` @@ -108,12 +108,7 @@ Now open a browser and navigate to your dev VM on port 6901. Running noVNC from source ------------------------- If you need to debug or make changes to the UI code, use the following procedures to use npm to serve the web code. The code will automatically rebuild when changes are made and the code will not be packaged. -These steps assume you have already built the docker image covered in the previous section named `kasmvnc:dev`. - -```bash -# run an instance of the dev container, expose an additional port -sudo docker run -it -v ./:/src -p 6901:6901 -p 8443:8443 --name kasmvnc_dev kasmvnc:dev -``` +These steps assume you are inside the kasmvnc:dev container started in the above steps. Now from inside the container. **This assumes KasmVNC is already built, follow steps above if you need to build KasmVNC** @@ -124,7 +119,7 @@ Now from inside the container. **This assumes KasmVNC is already built, follow s sudo nginx cd kasmweb -npm install +npm install # only needs done first time npm run serve # <-- Needs to run in foreground ```