diff --git a/BUILDING.txt b/BUILDING.txt index 34b6ab8..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 ``` @@ -105,6 +105,34 @@ 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 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** + +```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 # only needs done first time +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/builder/build.sh b/builder/build.sh index 332fd27..24d66c0 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -124,6 +124,7 @@ make -j"$(nproc)" # modifications for the servertarball cd /src mkdir -p xorg.build/bin +mkdir -p xorg.build/lib cd xorg.build/bin/ ln -sfn /src/unix/xserver/hw/vnc/Xvnc Xvnc cd .. 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 255e3c7..08ae041 100644 --- a/builder/dockerfile.ubuntu_jammy.dev +++ b/builder/dockerfile.ubuntu_jammy.dev @@ -10,6 +10,8 @@ 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 \ @@ -55,7 +57,7 @@ RUN sed -i 's$# deb-src$deb-src$' /etc/apt/sources.list && \ 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 COPY builder/scripts/build-webp /tmp COPY builder/scripts/build-libjpeg-turbo /tmp diff --git a/kasmweb b/kasmweb index 5c46b2e..0d8a3c5 160000 --- a/kasmweb +++ b/kasmweb @@ -1 +1 @@ -Subproject commit 5c46b2e13ab1dd7232b28f017fd7e49ca740f5a4 +Subproject commit 0d8a3c5f07defffe340dd67a1485be5214bec4ee