User Tools

Site Tools


wiki:advanced:x2gohtmlclient

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:advanced:x2gohtmlclient [2021/12/31 18:54]
mikep old revision restored (2021/12/31 18:36)
wiki:advanced:x2gohtmlclient [2022/10/03 13:34] (current)
gratuxri [proof of concept installation on Ubuntu GNU/Linux from Launchpad PPA]
Line 1: Line 1:
- 
 ====== Introduction ====== ====== Introduction ======
  
Line 9: Line 8:
   * python-websockify.   * python-websockify.
 X2Go provides instructions for configuring the NGINX web server, but you can substitute another server if you prefer. Your operating system distribution likely provides packages containing the dependencies not provided by X2Go. X2Go provides instructions for configuring the NGINX web server, but you can substitute another server if you prefer. Your operating system distribution likely provides packages containing the dependencies not provided by X2Go.
 +
 +{{:wiki:advanced:kdr.png?400|}}
  
 ====== Components ====== ====== Components ======
  
-===== X2GoHTMLClient =====+===== x2gohtmlclient =====
  
-==== index.html ==== +Contains the JavaScript and other assets that are served to a browser. The main page is ''index.html'', and it provides two modes: native client and an embedded client. The native client requires that a recent version of the X2Go client exists on the same computer as the browser. The embedded client provides the HTML5-based functionality. In any case, ''index.html'' prompts the user for: 
-Client HTML page. This page can be modified or embedded in existing webpage. It has two modes: native client and embedded client. User can use native client if recent version of X2Go client is installed on the system. In this case, the page will generate x2go session file, which will be automatically opened with x2go client. Second mode is to use embedded HTML Client (only supports X2GoKdrive). The HTML page provides user input for the next settings+  * the X2Go server address, 
-<code> +  * a username, 
-X2Go Server address +  * a password, 
-Username +  * the desktop environment to start
-Password +  * whether to use an SSH proxy, 
-Command to execute (KDEGNOME, ICEWM, etc) +  * an optional proxy username, and 
-SSH Proxy (if not specified no proxy will be used) +  * an optional proxy password.
-Proxy login +
-Proxy password +
-</code> +
-The HTML page can be modified to predefine one or more of this settings. Important functions inside of this page should be defined: +
-<code>function getServer() +
-function getUname() +
-function getPass() +
-function getCommand() +
-function getName() +
-function getProxy() +
-function getProxyUser() +
-function getProxyPass() +
-</code> +
-==== x2gokdriveclient.html ==== +
-The HTML Page to run X2Go client in separate window. By default the session's window is embedded in the start page. User can "detach" the session to separate window using "new window" button. After that session will be shown in the separate window and can be resized, opened in full screen, etc.+
  
-==== CSS/x2gostyle.css ==== +{{:wiki:advanced:client.png?400|}}
-WEB styles for HTML pages+
  
-==== SRC/*png SRC/*svg ==== +''index.html'' can be edited to set a default server and so on. 
-Image resources+The file ''x2gokdriveclient.html'' allows for running the X2Go client in a separate window.
  
-==== SRC/x2godomcontroller.js ==== +The x2gohtmlclient package also provides CSS, images, and three JavaScript classes: 
-Communication between HTML page and X2Go HTML Client +  -   ''x2godomcontroller.js'', which handles communication between the HTML page and the X2Go HTML client; 
-==== SRC/x2gohtmlclient.js ==== +    ''x2gohtmlclient.js'', which handles communication between the X2Go RPC script and the X2Go HTML client; and 
-Communication between X2Go RPC script and X2Go HTML Client +    ''x2gokdrivehtmlclient.js'', which implements the X2Go KDrive client.
-==== SRC/x2gokdrivehtmlclient.js ==== +
-X2GoKdrive JS client+
  
-===== x2gorpc.cgi ===== +===== x2gowebrpc ===== 
-CGI script for communication between HTML Client and X2Go server. It connects to X2Go server using ssh, starts/resuming sessions, opens SSH tunnels, etc+ 
 +The x2gorpc.cgi CGI script connects to the X2Go server using SSH and starts sessions, resumes sessions, starts SSH tunnels and so on in response to requests from the browser. This involves using SSH to run ''x2golistsessions''run ''x2gostartagent'', start a tunnel using SSH's ''-N'' and ''-L'' arguments, run ''x2goruncommand'', and run ''x2gowswrapper''.
  
 ===== x2gowswrapper ===== ===== x2gowswrapper =====
-The application which is connecting TCP sockets of X2GoKdrive agent with web sockets for HTML Client. 
- 
- 
-====== Building ====== 
- 
-====== JS classes ====== 
-JS classes should be compiled in one using script minify.sh. The resulting file x2goclient.js will be placed in subdir "dist" 
- 
-====== x2gowswrapper ====== 
-Build using qmake 
-<code> 
-$qmake-qt5 && make 
-</code> 
- 
-====== Installation ====== 
  
-Prerequements: Web Browser with support for CGI and Web sockets (for example nginx).+The x2gowswrapper program connects the TCP sockets of the X2Go KDrive agent with WebSockets created by the browser.
  
-Example of nginx configuration (in this case with fcgiwrap https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/)+====== Configuring the Web Server ======
  
-''/etc/nginx/sites-available/<your host>-ssl:''+We describe how to configure NGINX and fcgiwrap, but you can substitute any web server that provides the needed features. 
 +Here is an example NGINX configuration:
 <file> <file>
 server { server {
   listen 443 ssl;   listen 443 ssl;
   server_name your_host;   server_name your_host;
-  ssl_certificate <your SSL cert>+  ssl_certificate "/etc/pki/nginx/server.crt"
-  ssl_certificate_key <your SSL cert key>;+  ssl_certificate_key "/etc/pki/nginx/private/server.key";
   ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;   ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
   ssl_protocols TLSv1.2;   ssl_protocols TLSv1.2;
Line 93: Line 63:
   location /assets/ {   location /assets/ {
     add_header Strict-Transport-Security "max-age=31536000";     add_header Strict-Transport-Security "max-age=31536000";
-    add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' data: blob: ws: wss:; script-src 'self' 'unsafe-inline'+    add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' data: blob: ws: wss:; script-src 'self' 'unsafe-inline'";
     add_header Feature-Policy "vibrate 'none' ; microphone 'none' ; camera 'none' ; gyroscope 'none' ; magnetometer 'none' ; geolocation 'none' ; midi 'self' ; notifications 'self' ; push 'self' ; sync-xhr 'self'";     add_header Feature-Policy "vibrate 'none' ; microphone 'none' ; camera 'none' ; gyroscope 'none' ; magnetometer 'none' ; geolocation 'none' ; midi 'self' ; notifications 'self' ; push 'self' ; sync-xhr 'self'";
     add_header Referrer-Policy "same-origin";     add_header Referrer-Policy "same-origin";
Line 100: Line 70:
   }   }
  
-location ~* \.(pl|cgi)$ { +  location ~* \.(pl|cgi)$ { 
-  gzip off; +    gzip off; 
-  include /etc/nginx/fastcgi_params; +    include /etc/nginx/fastcgi_params; 
-  fastcgi_pass  unix:/var/run/fcgiwrap.socket;+    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
   }   }
  
-location ~ ^/x2gows/(.*)$ { +  location ~ ^/x2gows/(.*)$ { 
-  proxy_pass       https://127.0.0.1:$1; +    proxy_pass       https://127.0.0.1:$1; 
-  proxy_set_header Upgrade $http_upgrade; +    proxy_set_header Upgrade $http_upgrade; 
-  proxy_set_header Connection "upgrade"; +    proxy_set_header Connection "upgrade"; 
-  proxy_http_version 1.1; +    proxy_http_version 1.1; 
-  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
-  proxy_set_header Host $http_host; +    proxy_set_header Host $http_host; 
-  proxy_intercept_errors on; +    proxy_intercept_errors on; 
-  proxy_redirect off; +    proxy_redirect off; 
-  proxy_cache_bypass $http_upgrade; +    proxy_cache_bypass $http_upgrade; 
-  proxy_set_header X-Real-IP $remote_addr; +    proxy_set_header X-Real-IP $remote_addr; 
-  proxy_set_header X-NginX-Proxy true; +    proxy_set_header X-NginX-Proxy true; 
-  proxy_ssl_session_reuse off;+    proxy_ssl_session_reuse off;
   }   }
 } }
 </file> </file>
 +Note that the location ''/x2gows/PORT'' gets proxied to a process on localhost listening to PORT. The is the x2gowswrapper process.
  
-X2Go HTML client files: +====== Building and Installing ======
-<code> +
-<WEB ROOT>/assets/x2go-plugin/ +
-                             CSS/x2gostyle.css +
-                             IMG/*.png +
-                             IMG/x2gobg.svg +
-                             JS/x2goclient.js +
-                             RPC/x2gorpc.cgi +
-                             index.html +
-                             x2gokdriveclient.html+
  
-</code>+===== x2gohtmlclient ===== 
 + 
 +Run ''./minify.sh'' to combine x2gohtmlclient's JavaScript classes and remove the whitespace from the result. 
 +The output will be ''dist/x2gokdriveclient.min.js'', and you should copy this file to ''$WEBROOT/assets/js/''
 + 
 +The other assets should be installed as follows. Create the parent directories as required. 
 +  * Place ''index.html'' in ''$WEBROOT/''
 +  * Place ''css/*'' in ''$WEBROOT/assets/css/''
 +  * Place ''img/*/*/*'' in ''$WEBROOT/assets/img/''
 + 
 +===== x2gowebrpc ===== 
 + 
 +Copy ''x2gorpc.cgi'' to ''$WEBROOT/assets/rpc/''.
  
-This location can be changed, in this case the changes should be also done in the WEB Server configuration file and in index.html file:+===== x2gowswrapper ===== 
 + 
 +Build x2gowswrapper using qmake:
 <code> <code>
-var RPC_path="/assets/x2go-plugin/RPC/x2gorpc.cgi"; +$ qmake-qt5 && make
-var asset_path="/assets/x2go-plugin/IMG/";+
 </code> </code>
-x2gorpc.cgi should be executable+Install the resulting program named x2gowswrapper to ''/usr/sbin/''.
  
-install x2gowswrapper to /usr/bin+Create the directory ''/var/log/x2gows'', and ensure the web server's user can create and modify files therein.
  
-x2gowswarpper configuration: +Create the file named ''/etc/x2go/x2gows/x2gows.options'' that contains the following: 
- +<code>
-/etc/x2go/x2gows/x2gows.options +
-<file>+
 ws_proto=wss ws_proto=wss
-ssl_cert=<your SSL cert> +ssl_cert=/etc/pki/nginx/server.crt 
-ssl_key=<your SSL cert key>+ssl_key=/etc/pki/nginx/private/server.key
 ssl_only=true ssl_only=true
 log_dir=/var/log/x2gows log_dir=/var/log/x2gows
-</file+</code
-the SSL key should be same which used for WEB server.+Ensure the values of ''ssl_cert'' and ''ssl_key'' match the corresponding values in NGINX's configuration, 
 +and ensure the user running NGINX can read the files at both paths as well as the configuration file itself.
  
-Because x2gowswrapper is started from CGI, be sure that config and SSL Certs are accessible for web server user  (www-data in debian)+===== proof of concept installation on Debian GNU/Linux =====
  
-create log directory for x2gowswarpper: 
 <code> <code>
-#mkdir /var/log/x2gows +sudo apt install extrepo 
-#chown www-data /var/log/x2gows+sudo extrepo enable x2go 
 +sudo apt update 
 +sudo apt install x2gohtmlclient
 </code> </code>
  
-to use x2go HTML client open in web browser:+===== proof of concept installation on Ubuntu GNU/Linux from Launchpad PPA =====
  
 <code> <code>
-https://<your host>/assets/x2go-plugin/+sudo add-apt-repository ppa:x2go/nightly 
 +sudo add-apt-repository ppa:x2go/ppa 
 +sudo apt update 
 +sudo apt install x2gohtmlclient
 </code> </code>
- 
-{{:wiki:advanced:client.png?400|}} 
-{{:wiki:advanced:kdr.png?400|}} 
- 
wiki/advanced/x2gohtmlclient.1640976897.txt.gz · Last modified: 2021/12/31 18:54 by mikep