First, the official website address
Address: https://github.com/novnc/websockify
Second, open proxy
1, a single server
python /usr/local/websockify/websockify.py --cert /usr/local/websockify/self.pem 6080 192.168.20.134:5901
self.pem can be generated using OpenSSL, then placed in the directory, of course, may not add parameters cert
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
2, multi-node server
In practice, it is impossible for each virtual machine a proxy holder, the consumption of the port number is huge in this way, while VNC is usually integrated in the front page, is it possible that only one open port, and the realization agents multiple virtual machines, the answer is naturally possible.
In websockify project Wiki page ( https://github.com/novnc/websockify/wiki/Token-based-target-selection ) introduces the realization of a port, multiple proxy method.
In websockify project Wiki page describes the realization of a port, multiple proxy method.
This is the realization of the principle websocketproxy.py proxy token from a specified file directory read token, a token file generally corresponds to a client machine (VM). token file contents of the form token1: host1: port1, token1 here is a globally unique string identifier, a client host1 (VM) where ip address of the host, in the present embodiment is the ip Node1, and is port1 the client port number (virtual machine) VNC Server, and in this case it is the port number Guest1 of the VNC Server. Therefore, in this case called generic client (virtual machine) Guest1 the token contents of the file:
-
vnc123: 192.168.20.134:5901
-
vnc234: 192 .168 .20 .134 : 5902
-
vnc345: 192.168.20.133:5901
Note: a token file may correspond to a client (virtual machine), a token file may also correspond to multiple clients (virtual machine). In order to facilitate the programming and management, usually one to one relationship, unified placed in the token directory.
-
[root@node2 websockify]# ll /usr/local/websockify/token/
-
-rw-r--r-- 1 root root 28 5月 29 16:46 vnc123
-
-rw-r--r-- 1 root root 28 5月 29 16:46 vnc234
-
-rw-r--r-- 1 root root 28 5月 29 16:46 vnc345
3, start the agent
/usr/local/websockify/run --token-plugin TokenFile --token-source /usr/local/websockify/token/ 6080
If the token is a single file, you can start using the following command
/usr/local/websockify/run --target-config /usr/local/websockify/token/token 6080
Third, access vnc
Chrome, Firefox, and other browsers access (browser needs to support html5)
I myself own novnc according to the api documentation, write a simple demo, placed under nginx service http://192.168.20.111/vnc.html?token=vnc123
If you are starting websockify in novnc, you need to bring --web parameters, visit the following address http://192.168.20.121:8080/vnc.html?path=?token=vnc123
PS: Be sure to bring this parameter path =