Set a default welcome page in Jetty for static hosting /etc/openhab/html folder

* Platform information:
"systemInfo": {
    "configFolder": "/etc/openhab",
    "userdataFolder": "/var/lib/openhab",
    "logFolder": "/var/log/openhab",
    "javaVersion": "11.0.17",
    "javaVendor": "Azul Systems, Inc.",
    "javaVendorVersion": "Zulu11.60+19-CA",
    "osName": "Linux",
    "osVersion": "5.15.76-v8+",
    "osArchitecture": "aarch64",
    "availableProcessors": 4,
    "freeMemory": 29209456,
    "totalMemory": 187695104,
    "startLevel": 100

Running OH 3.3 Release build on Debian Linux:

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION="11 (bullseye)"
  • Issue of the topic: I want to set a default page for the static hosting at /etc/openhab/html

The openHAB platform allows for static hosting of files placed in /etc/openhab/html. This works fine, and files placed there can be accessed easily at http://openhab-ip-address/static/filename.ext.

However, I am trying to place an application in this folder which requires the url to end with /. Jetty allows for configuring a ‘welcome page’ according to Jetty documentation. For example,

<?xml version="1.0"  encoding="UTF-8"?>
    "-//Mort Bay Consulting//DTD Configure//EN"

  Configure a custom context for serving javadoc as static resources

<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
  <Set name="contextPath">/javadoc</Set>
  <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set>
  <Set name="handler">
    <New class="org.eclipse.jetty.server.handler.ResourceHandler">
      <Set name="welcomeFiles">
        <Array type="String">
      <Set name="cacheControl">max-age=3600,public</Set>

But I cannot find anywhere that this can be configured. It seems too easy to drop a file like this into the /etc/openhab/html folder and have Jetty pick it up?

So, to restate, in order to access /etc/openhab/html/index.html I must enter an url like http://openhab:8080/static/index.html, where I aim to access that same document via http://openhab:8080/static/.

Has anyone got any experience attempting to configure this, or a better source of documentation on how we can customize it?

Thanks in advance!

I think the file you are looking for would be /var/lib/openhab/etc/jetty.xml, but I don’t know enough about jetty to be able to guarantee that this will not break anything in the standard OH configuration. Is there a reason you need to serve this via OH instead of setting up e.g. nginx or apache to serve those files?

No, there’s no particular reason, just that I don’t want to install another service to maintain, version control, etc. if the static hosting can fit the bill. I had seen jetty.xml but my concern is that it doesn’t have a directive to listen on 8080 either so there has to be another subordinate configuration somewhere, which I am figuring is hidden inside Karaf somewhere. Unfortunately searching for all files containing the text ‘8080’ yields a result set too large to be usable.

Also, now I’m technically curious as to whether it can be figured out.