Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Virtual Host configuration

I have A/AAAA records set up for,,, and

The /webapps file folder now holds:


When browsing and entering any of the above URLs, I get the same result (following) on the screen, though the URL shown by the address line on the browser is whichever of the four variants was entered.

I can get the browser to display the desired content by adding /hexara or /adonax to any of the four urls. But I'm hoping to eventually get to where the browser address bar displays the url and the browser screen shows the index.htm for that domain, with no need to add the /hexara or /adonax.

Here are the contents of adonax_config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/adonax</Set>
  <Set name="resourcePath">./adonax</Set>
  <Set name="virtualHosts">
    <Array type="java.lang.String">

hexara_config.xml contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/hexara</Set>
  <Set name="resourcePath">./hexara</Set>
  <Set name="virtualHosts">
    <Array type="java.lang.String">

Did I get something wrong in these xml files?

I was inspecting WebAppContext and didn't see a reference to a method setResourcePath in the api, but did spot setResourceBase in a parent class ContextHandler. On the chance the terms "path" and "base" were accidentally mixed up, I tested using <Set name="resourceBase">
The resulting error may or may not add additional light to the situation.
Two additional items were added to the list of "known contexts".

Error 404 - Not Found.

No context on this server matched or handled this request.
Contexts known to this server are:
 Powered by Jetty:// 9.4.15.v20190215

Any suggested next steps?

-----Original Message-----
From: Peter Boughton <jetty@xxxxxxxxxxxxxxxxx>
To: jetty-users@xxxxxxxxxxx
Sent: Wed, Jun 24, 2020 4:51 am
Subject: Re: [jetty-users] Virtual Host configuration

Hi Phil,

> (1) The xml file examples are not given names. Is there an expected name
> or can they be named anything as long as they are in the correct
> directory location?

Yep, the name of the XML files is for your benefit, so use whatever is
appropriate/meaningful to you and your usage.

> (2) I'm pretty sure the xml file or files should be placed in
> /var/lib/jetty9/webapps. Correct? The manual says the files should go to
> $JETTY_HOME/webapps which ultimately resolves to this location.
> (JETTY_HOME is defined in a systemd jetty9.service file, and it contains
> a symlink to the above.)

The default location in a standard setup is $JETTY_BASE/webapps or - in
a non-standard setup - the directory jetty.deploy has been told to
monitor. There would be a file setting jetty.deploy.monitoredPath
somewhere, or just jetty.deploy.monitoredDir if it's still inside the
base dir just with a different name.
(That file could be start.ini or start.d/deploy.ini or whatever file
executes the command line. Running "java -jar start.jar --help" on the
command line give a bunch of information related to this, and should
also be in Chapter 9 of the docs.)

Some documentation still refers to JETTY_HOME because it was written
before the base/home separation was made and hasn't been updated yet.

Also, I'm not sure whether the Ubuntu repo version uses the home/base
distinction; if not, both home and base should be the same location.

> (3) The examples only show war files being set up. Can a static site, an
> index.htm be designated instead?

Yep, nothing special needed - just replace the War line with one setting
the resourcePath containing your static files, i.e:
    <Set name="resourcePath">/var/lib/jetty9/webapps/root/domaina</Set>

    <Set name="resourcePath">/var/lib/jetty9/webapps/domaina</Set>

You may want to replace the absolute path with a property so it's more
portable, or it can also be written relative to the jetty.base directory:
    <Set name="resourcePath">./webapps/domaina</Set>

> I'm assuming it would be valid to place the web content as follows...

Yep, but I would remove the "root" directory from those paths - i.e.
move domaina and domainb directories directly into webapps.

It would work either way (with appropriately configured resourcePath)
but they don't need to be inside the "root" dir, unless you have a
particular reason for them to be.

Hope that's all helpful - let me know if any parts are unclear.


jetty-users mailing list
To unsubscribe from this list, visit

Back to the top