![]() | CloudTk FAQ |
![]() |
CloudTk is based on WebSockit2me - a TCP to WebSocket gateway that uses a noVNC to display Tk applications in modern Web Browser. It runs on Linux and requires Xvnc server (Tigervnc) to be loaded. Tk applications are listed on a web page. TclHttpd dynamically launches an Xdisplay via Xvnc and then starts a matchbox window manager and launches the Tk application.
TclHttpd is a pure Tcl implementation of a Web server. See
A Tclkit is a single-file executable that provides a complete Tcl and Tk runtime and can execute both normal Tcl scripts or script archive files known as StarKits. Tclkit is provided pre-built for a number of platforms and is updated to track Tcl releases for the major platforms (Windows, Linux and MacOS X).
For pre-built files see the Tclkit Downloads page.
See also Brent Welch's sample book chapters from Practical Programming in Tcl and TK.
A Starkit is a single-file packaging of a directory hierarchy containing Tcl scripts, platform-specific compiled code, and application data. A starkit leverages Tcls virtual filesystem to provide writeable filesystem, meaning that a starkit is modified at runtime as data is saved by the program.
Starkits facilitate simple deployment of cross platform applications.The name comes from STandAlone Runtime.See also Brent Welch's sample book chapters from Practical Programming in Tcl and TK.
The default http port is 8015.
The default https port is 8016.
LibreSSL 3.1.2
CloudTk is configured to use TLS 1.2 only. Modern browsers that support WebSockets will support TLS 1.2 also.
On startup CloudTk creates a directory Tk/TkPool in the same directory CloudTk.kit is installed. A sample application TkPool.tcl and a startup script TkStartup.tcl are copied into this directory.
Point your browser to http://<<Your IP Address>>:8015/cloudtk/
A web page with a radio button with TkPool is display. Select the radio button and click submit. The TkPool application is displayed. Click below the white line and start to play.
Create a directory with the Tk or X11 application name in the Tk/ directory like TkPool. The directory name is what is displayed in the webpage but this can be anything really. Copy the TkStartup.tcl file from the TkPool directory into your directory. Open TkStartup.tcl file in a text editor and edit the line starting with the command "source" and adjust the path to where your Tk application is. TclHttpd does not need to be restarted as the web page is generated on the fly. The web page should display two radio buttons. TkPool and the directory name you created. If you do not want TkPool to be displayed just delete the TkPool directory.
N.B. If you are running an X11 application (or older Tk app less than Tcl8.6) replace the "source" command with an "exec" command and the full path of your application.
e.g. exec /usr/bin/python3 /usr/local/cloudtk/Tk/FeetToMeters/FeetToMeters.py
e.g. exec /usr/bin/xclock
e.g. exec /usr/local/tclkit-8.4.18 /usr/local/cloudtk/Tk/GooWee/GooWee.tcl
e.g. exec /usr/bin/docker run --rm -i --cpus 0.1 -e DISPLAY=$env(DISPLAY) -v /tmp/.X11-unix:/tmp/.X11-unix --net=host gearanimation:1
Put a link to your Tk application like for example TkPool
http://<<Your IP Address>>:8015/cloudtk/VNC?session=new&Tk=TkPool
Make sure the first query parameter is "session=new"
By using inline frame <iframe> HTML tag in your Web page.
Put a link to your Tk application like for example TkPool
<iframe height="600" width="600" src="http://<<Your IP Address>>:8015/cloudtk/VNC?session=new&Tk=TkPool" allowfullscreen></iframe>
Make sure the first query parameter is "session=new"
CloudTk has the ability to turn on Authentication for any combination of Tk Application page and the rest of CloudTk website pages.
In the directory where CloudTk.kit is installed an "auth" directory is created. In this directory there is an "AuthTarget.txt" file. The following is written to "AuthTarget.txt" file by default:
VNC 0
Website 0
"1" equals Authentication is "ON" and "0" is "OFF".
Just edit this file to your requirements.
To change the http port use -port <port no.> on the command line.
To change the https port use -https_port <port no.> on the command line.
e.g. ./tclkit CloudTk.kit -port 8080 -https_port 8443
Don't turn off HTTP by setting -port 0 on the command like
e.g. ./tclkit CloudTk.kit -port 0
This actually lets the OS choose a random high port to listen on.
To stop access to the HTTP port I would suggest filtering via a firewall or router and only allow access to HTTPS port.
Another solution would be to set the ip address for HTTP requests to the Loopback address of 127.0.0.1.
e.g. ./tclkit CloudTk.kit -ipaddr 127.0.0.1
To setup HTTPS, a Server certificate (server.pem) and a Server key (skey.pem) file need to be installed in the "certs" directory that is created where CloudTk.kit is installed. Openssl needs to be installed to generate a self signed certificate. On most Linux distributions this is usually standard.
/usr/local/cloudtk/certs# openssl req -new -x509 -days 365 -nodes -out server.pem -keyout skey.pem
Hit the "Enter" key to accept the defaults to the questions.
This creates a server.pem and a skey.pem file in the "certs" directory. Restart CloudTk and now HTTPS should be configured.
Point your browser to https://<<Your IP Address>>:8016/
To use Let's Encrypt copy from Let's Encrypt the fullchain.pem file to server.pem and privkey.pem file to skey.pem in the "certs" directory. Restart CloudTk and now HTTPS should be configured.
In the directory where CloudTk.kit is installed an "auth" directory is created. In this directory an AuthUserFile exists which has the webmaster username and password. Copy the contents of your htpasswd file and paste into the AuthUserFile. If you go to the Access Control Editor you should see the new users added.
Download the noVNC master(master.zip or latest stable release) to the same directory where CloudTk.kit is installed. Unzip master.zip and a "noVNC-master" directory will be created. Rename the "noVNC-master" directory to "noVNC" directory.
e.g. mv noVNC-master/ noVNC/
Restart CloudTk and it should detect the created "noVNC" directory and use the new version of noVNC. To go back to the inbuilt version of noVNC included with CloudTk just delete the "noVNC" directory you just created. If error messages appear in your browser after upgrading you may have to clear the browser cache.
You need to be familiar with how to create an "rc" script on your Linux distribution. The "rc" script would execute a shell script that you create usually in /usr/local/bin.
Create a shell script in /usr/local/bin with the following
#!/bin/sh
exec /usr/local/cloudtk/tclkit /usr/local/cloudtk/CloudTk.kit -port 8080 -https_port 8443
Most modern Linux distributions use Systemd. Refer to the man page.
1. A site wide configuration file CloudTk.conf in the Tk/ directory. In this file are the state array variables to control certain aspects of server.
2. For application specific configuration, copy CloudTk.conf to any of the Tk/<app-directory-name> and rename CloudTk.conf to <app-directory-name>.conf. The settings you adjust in <app-directory-name>.conf will take precendence over the site wide Tk/CloudTk.conf file. Therefore using the TkPool app as an example, copy the Tk/CloudTk.conf file to Tk/TkPool/TkPool.conf
3. For per session specific configuration , you can add any of the state array variables used in the CloudTk.conf file as Url query data when launching your application. See FAQ 2.16 Per session query data takes precendence over <app-directory-name>.conf and CloudTk.conf
Within the Starkit of CloudTk.kit there is a htdocs/ directory which is the document root of the web server. This has an index.tml file in this directory and other html files. I have exposed a htdoc/ directory in the same directory CloudTk.kit is installed. Therefore you can create a new index.html or index.tml file or other files in this outside htdoc/ directory and CloudTk will deliver them to a web browser. If the same file name is in the outside htdocs/ directory of the CloudTk.kit it takes precedence over the file with the same name inside the CloudTk.kit.
The main file that launches the noVNC app is called vnc.html and this is in the noVNC/ directory where you have CloudTk.kit installed. This file has javascript in it for the noVNC menu (control tab). The noVNC developers modified vnc.html when going from noVNC 1.3.0 to 1.4.0. I have modified the vnc.html file with some javascript.
In the download directory for CloudTk
http://cloudtk.tcl-lang.org/Downloads/
the following files
vnc-fullscreen-130.html
vnc-fullscreen-140.html
vnc-fullscreen-clipboard-130.html
vnc-fullscreen-clipboard-140.html
vnc-no-control-tab-140.html
vnc-notab-130.html
These are the files I used for adjusting the noVNC control tab in version 1.3.0 (CloudTk-130-xx.kit) and then 1.4.0 (CloudTk-140-xx.kit).
There are a few ways to use these files
1. You could move the current vnc.html to vnc.html.orig and then download for example vnc-fullscreen-130.html to the noVNC/ directory and rename it vnc.html.
2. Download for example vnc-fullscreen-130.html to the noVNC/ directory. Edit the CloudTk.conf under the Tk/ directory by changing from
state noVNC,html vnc.html
to
state noVNC,html vnc-fullscreen-130.html
3. If you just want to change the noVNC control tab for one application then you can create a configuration file that only effects that application. To do this copy the Tk/CloudTk.conf file to Tk/<app-directory-name>/<app-directory-name>.conf. So for TkPool application you would copy Tk/CloudTk.conf to Tk/TkPool/TkPool.conf. Then you would edit TkPool.conf as per number 2 above.
4.Another way to change the noVNC control tab for one application is to create a <app-directory-name>_vnc.html file in the Tk/<app-directory-name>/ directory. So for the TkPool app you would copy for example vnc-fullscreen-130.html to Tk/TkPool/TkPool_vnc.html.
You need to be using a later version of CloudTk. The latest release at the time of writing is CloudTk-140-50.kit available from the Downloads directory on the Cloudk website
http://cloudtk.tcl-lang.org/Downloads/
Query parameters of the form TkArgs,xxxx are made available as argv arguments to the TkStartup.tcl script which launches your application. So for example to pass the arguments user=foo, password=bar, directory=/home/foo, file=test.txt to the TkPool app the url would be
https://youraddress:8016/cloudtk/VNC?session=new&Tk=TkPool&TkArgs,user=foo&TkArgs,password=bar&TkArgs,directory=/home/foo&TkArgs,file=test.txt
You should see the arguments passed to the TkStartup file by checking the process with
ps x
582756 pts/0 Sl+ 0:01 ../tclkit-8.6.3 CloudTk-130-48.kit -port 8080 -debug 1
582774 pts/0 Sl+ 0:00 /usr/bin/Xvnc :51 -geometry 1024x768 -fp -localhost -desktop TkPool SecurityTypes=None
582775 pts/0 S+ 0:00 /usr/bin/matchbox-window-manager -display :51 -use_titlebar yes
582776 pts/0 Sl+ 0:00 /usr/local/cloudtk/Test/../tclkit-8.6.3 /usr/local/cloudtk/Test/Tk/TkPool/TkStartup.tcl -display :51 -user foo -file test.txt -password bar -directory /home/foo
each of the variable names are converted to lower case and have - in front of them.
You would need to put some javascript in the page that you launch your application from to obtain the screen width x height like
https://www.tutorialrepublic.com/faq/how-to-detect-screen-resolution-with-javascript.php
then using Javascript somehow append it to the URL as a query parameter that launches CloudTk (Sorry I dont know how to do this with Javascript). So for example we are using the TkPool app. If the Javascript detects your device has a screen resolution of 800x600 then the javascript would insert 800x600 after the Xvnc,geometry= so the CloudTk URL would be
http://<<Your IP Address>>:8015/cloudtk/VNC?session=new&Tk=TkPool&Xvnc,geometry=800x600
So for this instance of TkPool, the Xvnc server geometry will be 800x600 on startup.
Youll notice Xvnc,geometry is one of the state array names used in the CloudTk.conf. You can include any of these as a query parameter to control individual instance of an app on CloudTk. The only state array names that can not be controlled via a query parameter are Xvnc,exec and Xsetroot,exec.
You could also add a TkArgs query parameter if you wanted to pass it as argument to your X11 application like
http://<<Your IP Address>>:8015/cloudtk/VNC?session=new&Tk=TkPool&Xvnc,geometry=800x600&TkArgs,geometry=800x600
The mesages that appear like below:
can't find package limit
Running with default file descriptor limit
/debug user "debug" password "XXXXXXXXXX"
httpd started on port 8015
secure httpd started on SSL port 8016
The first two lines can be ignored as they are just informational messages.
The /debug line shows the username and password for the user "debug". This is used when the server encounters an error in a Tcl script, the server requires authorisation from the user "debug" before the error message is displayed.
The "httpd started on port 8015" informs that the server started and is listening on port 8015.
The "secure httpd started on SSL port 8016", this message appears if there is a server.pem file present in the "certs" directory. It informs that the server will be listenining for https connections on port 8016.
![]() | |||
Home | /kanaka/noVNC | FAQ | Access Control |