[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Fwd: Re: Forwarding virtual host requests to another server
|
[Apologies to Chris; I just realised that I replied to him directly
instead of to the list...]
On 08/11/2017 20:47, Chris Walker wrote:
John,
You could look into accomplishing this with the MovedContextHandler
<https://www.eclipse.org/jetty/documentation/current/moved-context-handler.html> (Javadoc
here
<https://www.eclipse.org/jetty/javadoc/9.4.7.v20170914/org/eclipse/jetty/server/handler/MovedContextHandler.html>) or
making use of the ProxyServlet
<https://www.eclipse.org/jetty/documentation/current/proxy-servlet.html>.
Hi Chris,
I've been trying to get a ProxyServlet to work. What I have done so far:
1) in the webapps directory, I've created a "proxy" directory containing
an index.html, and a proxy.xml as follows:
<?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">/</Set>
<Set name="war"><Property name="jetty.webapps" default="."/>/proxy</Set>
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item>127.0.0.2</Item>
</Array>
</Set>
</Configure>
If I go to 127.0.0.1, I get my main webapp (which has 127.0.0.1 in its
virtualHosts entry), and if I go to 127.0.0.2, I get my new index.html.
So far so good.
2) I've created a simple ProxyServlet, compiled it successsfully, and am
ready to test further. At this point I get lost in a maze of twisty
little Jetty configuration problems.
2a) I get a startup error: "ProxyServlet not found." Oops, forgot to add
the "proxy" module to my start.ini.
2b) Having added --module=proxy to my start.ini (using
--add-to-start=proxy), I now get a different startup error:
2017-11-15 14:49:19.678:WARN:oejx.XmlConfiguration:main:
java.lang.NoClassDefFoundError:
org/eclipse/jetty/server/handler/HandlerWrapper
and also
2017-11-15 14:51:44.242:WARN:oejx.XmlConfiguration:main:
java.lang.NoClassDefFoundError: org/eclipse/jetty/util/Attributes
And then the server terminates. I've tried everything I can think of but
can't figure out what I need to do to fix this. If I take out
--module=proxy from start.ini, the server keeps running and I can access
my main webapp, but then I'm back to 2(a) again.
This is what --list-config tells me:
Jetty Server Classpath:
-----------------------
Version Information on 13 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the --module=name command line options will be
reflected here.
0: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-client-9.4.6.v20170531.jar
1: 3.1.0 | ${jetty.base}\lib\servlet-api-3.1.jar
2: 3.1.0.M0 | ${jetty.base}\lib\jetty-schemas-3.1.jar
3: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-http-9.4.6.v20170531.jar
4: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-server-9.4.6.v20170531.jar
5: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-xml-9.4.6.v20170531.jar
6: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-util-9.4.6.v20170531.jar
7: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-io-9.4.6.v20170531.jar
8: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-security-9.4.6.v20170531.jar
9: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-servlet-9.4.6.v20170531.jar
10: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-webapp-9.4.6.v20170531.jar
11: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-deploy-9.4.6.v20170531.jar
12: 9.4.6.v20170531 |
${jetty.base}\lib\jetty-proxy-9.4.6.v20170531.jar
Jetty Active XMLs:
------------------
${jetty.base}\etc\console-capture.xml
${jetty.base}\etc\jetty.xml
${jetty.base}\etc\jetty-webapp.xml
${jetty.base}\etc\jetty-deploy.xml
${jetty.base}\etc\jetty-ssl.xml
${jetty.base}\etc\jetty-ssl-context.xml
${jetty.base}\etc\jetty-https.xml
${jetty.base}\etc\jetty-proxy.xml
${jetty.base}\etc\jetty-requestlog.xml
jetty-util-9.4.6.v20170531 (for Attributes) and
jetty-server-9.4.6.v20170531 (for HandlerWrapper) are both in the lib
directory. I've also added them to the Eclipse build path but that
doesn't make any difference either. They don't appear in the server
classpath for some reason.
Any advice please?
--
John English