Skip to main content

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

Hi Phil,

Firstly I would suggest you update to the latest version of Jetty (version 9.4.30). The version you are on is subject to various security vulnerabilities, and there has been numerous other improvements and updates since 9.4.15.

I'm not sure your resourcePath is correct, maybe try using something like:
<Set name="resourceBase"><SystemProperty name="jetty.base"/>/webapps/hexara</Set>

The documentation at https://www.eclipse.org/jetty/documentation/current/configuring-virtual-hosts.html describes how you can "Using Different Sets of Virtual Hosts to Select Different Contexts at the Same Context Path". So if you map both of your webapps to the same contextPath (ie <Set name="contextPath">/</Set>) it would decide which one to use based off the list of virtual hosts you are providing.

ps. for some reason your emails are being sent to spam by the Gmail filter.

Cheers,
Lachlan

On Fri, Jun 26, 2020 at 2:06 PM <philfrei@xxxxxxx> wrote:
I have A/AAAA records set up for adonax.com, www.adonax.com, hexara.com, and www.hexara.com.

The /webapps file folder now holds:


adonax/
hexara/
adonax_config.xml
hexara_config.xml

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" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<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">
      <Item>www.adonax.com</Item>
      <Item>adonax.com</Item>
    </Array>
  </Set>
</Configure>

hexara_config.xml contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<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">
      <Item>www.hexara.com</Item>
      <Item>hexara.com</Item>
    </Array>
  </Set>
</Configure>

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>

or:
    <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.


Thanks,


Peter
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top