How can i force Jetty to open all deployed webapps starting from specific virtual host like test.localhost:8080/myapp
instead of localhost:8181/myapp
?
Here's snippet from jetty.xml:
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">
<Property name="jetty.host"/>
</Set>
<Set name="port">
<Property name="jetty.port" default="8181"/>
</Set>
...
... i tried to play with jetty.host
value but still no success. :(
How to?
To LISTEN on a specific network interface, you specify that interface either via its IP address (IPv4 or IPv6) or its hostname.
Since this is a variant of localhost / loopback, then using IP address would be best.
Eg:
$ grep localhost /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.1.0 test.localhost
Yes, those hosts are on different IPs, intentionally (and valid for the loopback interface).
You could then setup the connector, using the jetty-distribution, for test.localhost:8080
by using the command line (this is jetty 9 syntax)
$ java -jar /path/to/start.jar jetty.host=127.0.1.0 jetty.port=8080
You can also put those command line options into your ${jetty.base}/start.ini
as separate lines.
$ grep -E "jetty\.(host|port)" /path/to/my.base/start.ini
jetty.host=127.0.1.0
jetty.port=8080
Once jetty is started, you can see what interface it is listening on
$ netstat -tlnp | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp4 0 0 127.0.1.0:8080 :::* LISTEN 14480/java
来源:https://stackoverflow.com/questions/26326436/jetty-set-up-general-host