Skip to content

Guacamole Liberty Profile Stack on systemd

If you are using Apache Guacamole to access your computers via VNC, RDP or SSH, you might be interested on how to run this web application (war file) as Guacamole Liberty Profile Stack (i.e. on IBM Websphere Liberty Profile). Additionally, you can start the IBM server with systemd to see the console logs in journalctl. Although Liberty Profile is a licenced and proprietary product by IBM, it is free of charge for non-production purposes and development.

Why choose Apache Guacamole

If you want to access your home or remote computer, you might just want to use a ssh tunnel and then VNC or RDP (Windows). But using SSH is not always possible due to firewall or other protocol restrictions. In this case, you might want to try Apache Guacamole to access your home LAN or remote server or desktop. I’ve been using the Guacamole web application for years now. Sadly, development stalled, but it is still a great HTML5 web application which streams jpgs or pngs via AJAX/websocket to your client browser. This way, you can access your data fast and secure (if you’re using https/TLS).

Apache Guacamole Logo, © Apache Foundation, Apache Licence 2.0. Source: <a href="">Github</a>
Apache Guacamole Logo, © Apache Foundation, Apache Licence 2.0. Source: Github

Guacamole consists of two parts: A client application (which is the java web archive) and the guacd server, written in C. Guacd (the server) will not be handled in this guide. The java web application (guacamole.war) can run on any servlet container like Apache Tomcat, Jetty, JBoss and others.

Why choose IBM Liberty Profile

Although IBM Liberty Profile can do much more like JavaEE7.0, it is also very lightweight, fast and uses few resources. Plus you can use it with no fees (although it is unfree in an open source sense), but itself uses open source software, like Apache CXF and others.

Liberty Profile is also very flexible. One installation can run various webapps or enterprise applications using different Java virtual machines. For example, an Oracle Java 8 64bit, and another one IBM J9 8 32bit. With tomcat or jetty, you would need copies of the entire application folder. IBM Liberty Profile on the other hand uses a simple directory structure. For each web application there is a directory ${wlp.install.home}/usr/servers/${servername} . For each server, you can configure the java by setting  the JAVA_HOME variable in the file server.env  — think of it as a simplified .profile / .bashrc  file with environment variables only specific to this server. I will go into detail later.

Additionally to the reasons stated above, there are other advantages: On IBM LP, you can (de-)activate various container features. By default, nothing specific is activated. The startup time is very fast with liberty profile, if you don’t use a lot of features. Think of every Java API  as a feature: Servlets, WebSockets, Mail, Beans, CDI, JAX-RS, JAX-WS… or bundles like JavaEE-Web and JavaEE-Full. Load as few as possible for a very fast server.

Why choose systemd over Upstart

Today, most Linux distributions will use systemd. The *BSD folks don’t like it, because they think it violates the *nix philosophy. Anyway, it consists of many small programs, each having exactly one job. Also, it provides an easy interface for starting daemons and reading logs. As choices vanish in modern distributions, I’ll explain how to handle Liberty startup using systemd.

Installing Java and Liberty Profile

Installing Java

You can choose any java you like. You can just use your distribution’s java. But please keep in mind that Oracle’s and IBM’s java distributions are highly optimized and more recent.

If you chose to use another java, I’d suggest to just extract the package to a path like /opt/java/oracle-sdk8u112-linux-x64  or /opt/java/ibm-sdk-x64  and symlinking /opt/java/java  to your preferred default.

Installing IBM Liberty Profile

Download the IBM Liberty Profile zip. You can extract it at any location. I always use /opt/ibm/wlp , because corporate IBM packages will also use /opt/ibm , and wlp is a nice and short name for Websphere Liberty Profile.

Actually, that’s it. You installed all you need for your liberty profile. 🙂

Setting up the Guacamole Liberty Profile Stack

Creating a Guacamole Liberty Profile Server Instance

Probably the second most easy part in this tutorial is to create a new Guacamole Liberty Profile instance. Just cd  to the folder you just created an run this command:

That’s it! Now you have a new instance in this path: ${wlp.install.dir}/usr/servers/guacamole . Change into that directory to continue.

The first thing we want to do is to put our webapplication there. In the subfolder apps, link or copy the guacamole.war file. I always drop the file as guacamole-<version>.war  and create a symlink named guacamole.war , so I can switch to another version easily in case something goes wrong with an update.

Setting up the Server’s Environment file

This is the environment file for this guacamole liberty profile instance. We just need two options here: JAVA_HOME and GUACAMOLE_HOME. The first one specifies which JDK/JRE (Java Runtime) to use. If we set it to /opt/java/java  the most current Java is always used. To use a more recent one in the future, just change the symlink and leave all liberty instances as they were.

The second one is an application property, i.e. a property which belongs to guacamole and not to the container. You can use any path, though here are some suggestions:

  • Don’t set it and create a $HOME/.guacamole/  file afterwards.
    Select this method if you want this liberty instance run by another user with reduced priviledges.
  • Set it to a system-wide path like /etc/guacamole .
    Select this option, if you want to keep your configuration separate.
  • Set it to ${server.config.dir}/properties .  The advantage is that the properties reside with the liberty profile container instance, thus making it portable. Said in other words: just tar.gz the server instance directory to backup everything.

My server.env  file looks like this:

I decided to put the  file into the /etc/guacamole-directory, because of transition reasons (my old stack was not guacamole liberty profile, but guacamole jetty). If you want, you can also override your Java installation by setting JAVA_HOME=<path>  in here.

Setting up the server configuration server.xml

The file server.xml  contains the actual container (infrastructure) properties of your guacamole liberty profile server instance. We can define datasources or keystores here, but we don’t need any of those for guacamole. Guacamole only requires a servlet engine and (optionally) websockets. I’d recommend enabling websockets, as they will speed up things, less connections are needed. Both requirements are called “features” in liberty, and can be enabled by just adding a corresponding tag to the server.xml  file.

Additionally we can configure that there will be only one application named guacamole.war . The default is to check the dropins-directory every few seconds and deploy the found applications. This is useful for development but not needed in our case.

Additionally you want to configure unpacking the archive (option autoExpand ). This will enable us to serve static resources using nginx and the try_files  directive. The whole file will look like this.

You can change the bind hostname and ports, but everyhing else will expose your guacamole liberty profile instance. Hence I recommend to keep localhost. Consequently you should use a proxying webserver like nginx to server static files. For testing, however, you can just insert an asterisk (*) to make it available on all interfaces.

Please also note that I set the context root to “/”. Using this configuration it is like having a ROOT.war  in tomcat, which will have no subdirectory/path on the guacamole liberty profile server.

Creating a wrapper script (optional)

In journalctl (systemd logs), you might want to identify the server process more easily. The caveat is that systemd prints the executables name in the front, which is just «server». Not a pretty name, huh? To solve this issue, just create a script called /usr/local/sbin/guacamole-web . Paste the following contents:

Don’t forget to chmod +x  this script. If you use this script in your systemd unit file, libertys guacamole instance will appear as guacamole-web, not as plain server.

Configure nginx for IBM Liberty with Guacamole

Probably the most tricky part is configuring nginx properly. The idea is to use nginx as an SSL/TLS Proxy, which will also redirect requests to TLS when the user does not enter the https protocol. Also, I like to have separate logfiles for each virtual host. Furthermore I included serving static files for the files residing in the .war  archive. To make this work, we had to configure autoExpand in the liberty instance’s server.xml  (see above).

Nginx’ try_files is the ideal command for this task. It is the recommended method to check for files and much faster than a plain if statement.

Additionally, you might have noticed various includes. You can grab those starting with h5bp on github, they have a solid configuration which will work fine in most situations. Another include is just a .well-known directory I use with let’s encrypt — if you are looking for a free and easy-to-use certificate, this is the place to go. The snippet/letsencrypt.conf can also be found on github.

Probably the most interesting part is the @libertyguac  location. It is the  try_files  last alternative to find a file. Please notice that the first part of try_files is actually a directory. Assuming you are using guacamole 0.9.9, your directory will look like this:

Back to the location part: Liberty can maintain it’s own access log. Hence I usually turn this off for liberty redirects. Then we need headers, because liberty and guacamole need to know that they only got a redirected request. As a result, lots of proxy headers were added to the @libertyguac  location. Finally, the most important line is the proxy_pass statement of this section. All requests will get redirected to this URL, which happens to be our running guacamole liberty profile instance.

And that’s all about it. Test your configuration using nginx -t  and then reload or restart the nginx service using systemctl restart nginx.service .

Create a systemd unit file (init-script)

Now that we have a working liberty profile guacamole server, and an nginx proxy. Nginx will automatically start on boot as it is an ubuntu-shipped package. Opposite is true for IBM Websphere Liberty Profile. Because we installed it manually, we will need to write your own systemd unit file. Luckily, this has become much easier than with SysVInit or Upstart. Almost everything that neets to be done is to  create a file called  /etc/systemd/system/guacamole-web.service  having these few lines as content:

First of all, most of these lines are even not needed but nice-to-have. Especially environment file must exist if you use this option. It may contain a JAVA_HOME  variable. An empty file or removing this line will also do.

The option ReadWriteDirectories  is another security measure. It will prevent liberty to read files from other directories or to write to them. Another option WorkingDirectory  will make systemd cd  to that beforehand. Since we are using a wrapper script, we could implement the command there as well. Yet both will do fine.

If you don’t want to fiddle with a custom service user, you can also remove the lines User and Group. It is another security measure which will prevent access to other files, because in this case the guacamole liberty profile server will not run as root.

Websphere Liberty Profile im journalctl von systemd, es läuft Guacamole.
Websphere Light: Liberty Profile on journalctl of systemd running Guacamole.

Try starting your guacamole liberty profile server using systemd start guacamole-web.service . Whether it works or not, you can view the log output by using journalctl -u guacamole-web -exf . It will look like in the screenshot above.


With IBM Liberty Profile, it is very easy to set up a guacamole server. Also, IBM Websphere Liberty Profile plays nice with the web server nginx, which is a big plus. Enabling additional features is easier than in most of the others java web application servers. Therefore I consider the guacamole liberty profile stack a good option.

Guacamole on Enlightenment (E17) desktop using VNC on a scaled browser
Guacamole on Enlightenment (E17) desktop using VNC on a scaled browser

Guacamole runs very smoothly on liberty profile, and I never had any problems with it. You can see my scaled enlightenment- (e17-) desktop running in the screenshot above. Backing up the whole server is just zipping a single server directory. The only downside I found were the logs which tend to have very long lines. Also, the licence can be problematic as it may only be used for development and limited production use. It is also non-free (but guacamole is).


Image Attributions

  • Apache Guacamole Logo, © Apache Foundation.
    Apache Licence 2.0, Licence Text on Github.
    Original Image on Github.
  • IBM Websphere Liberty Profile Logo, © IBM
    All Rights reserved
    Original Logo on IBM Website
Published inHow TosIT Stuff

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *