I apologize for the previous oversight concerning the launch.sh script in the noVNC utils directory. It appears my instructions were based on an outdated version of noVNC, where launch.sh used to exist as a convenient script to start websockify and serve the noVNC HTML content.
In the more recent versions of noVNC, you need to manually use websockify to set up the WebSocket to VNC server bridge. Let's revise the instructions, adapting them to the current noVNC setup.
Step 1: Install a VNC Server on Ubuntu
-
Install TigerVNC Server:
sudo apt update
sudo apt install tigervnc-standalone-server tigervnc-common
-
Launch the VNC server:
vncserver :1
Set a secure password when prompted.
Step 2: Install noVNC
-
Clone noVNC from GitHub:
git clone https://github.com/novnc/noVNC.git
-
Install websockify:
cd noVNC
sudo apt install python3-websockify
Step 3: Set Up Nginx with SSL
-
Install Nginx and Certbot for SSL:
sudo apt install nginx certbot python3-certbot-nginx
-
Use Certbot to set up an SSL certificate:
sudo certbot --nginx -d yourdomain.com
-
Configure Nginx for noVNC:
Create a new server block or modify the existing one:
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / {
proxy_pass http://localhost:6080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Replace "yourdomain.com" with your actual domain. Then, reload Nginx:
sudo systemctl reload nginx
Step 4: Start Websockify to Connect noVNC to VNC Server
- Use websockify to start the WebSocket proxy:
websockify --web=./noVNC 6080 localhost:5901
This command tells websockify to serve the content of the noVNC directory on port 6080 and to tunnel WebSocket connections to the local VNC server running on port 5901 of localhost.
Step 5: Access VNC Through Your Browser
Open your browser and navigate to:
https://yourdomain.com/vnc.html
You'll be directed to a web interface from which you can securely access your VNC server. Use localhost:5901 as the target in the noVNC interface.
This revised guide should help you correctly set up a recent version of noVNC with a secure HTTPS connection via Nginx. It integrates modern best practices for maintaining a secure connection between a browser and a remote Ubuntu VNC server.