Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] virtual hosts jetty v9

Virtual Hosts configuration has 2 matching modes.
  1. The "Host:" request header.
  2. Named connector matching.
Using the Host request header, you would need to know what the hostname and/or port are for the incoming requests, and setup the virtualHosts for those values.  (I often just look at the chrome network inspection panel information)

Set those values in the virtualHosts section.

In other words, you have IP
A connector on that IP, port 8080
There are 2 hostnames for that IP

A request on would be against Host ""
A request on would be against Host ""
A request on would be against Host ""

Set the virtualHost configurations to those names.
Don't forget to set the hostname only and the hostname:port versions as well.

Also, for those people that insist on using the IP version, like, you'll want to decide what webapp you want to display to them, maybe even a 3rd webapp that tells them they messed up and should use the correct name.

If you want to use the Named connector matching, you'll have 2 connectors, then use the named connector matching.

Connector 1, on the internal IP and/or port: with name "internal"
Connector 2, on the external IP and/or port: with name "external"

webapp A: virtualHost of "@internal"
webapp B: virtualHost of "@external"

Just note that using named connectors and virtual hosts would rely on you not accidentally exposing an internal ip:port combo to the outside world, because if they can connect to that ip:port address then they can use whatever webapp that @name is bound to.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Fri, Oct 17, 2014 at 4:20 PM, Jokrummy Pointcom <jokrummy@xxxxxxxxxxx> wrote:
Hello jetty users,

I need help setting up virtual hosts. I run jetty v9 within Smartfoxserver which is for game development. Currently I have 2 games. The structure looks like this:

/home/fo/SmartFoxServer_2X/SFS2X/www/root/index.html  is the index of game 1

/home/fo/SmartFoxServer_2X/SFS2X/www/jok/index.html  is the index of game 2

/home/fo/SmartFoxServer_2X/SFS2X/lib/jetty/  is the home directory of jetty

What I need to do is simply, if the user access the server via my public IP instead of the domain, serve him the index.html from game 2.

I created a context xml file in the directory


The file contains:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/home/fo/SmartFoxServer_2X/SFS2X/www</Set>
  <Set name="resourceBase">/home/fo/SmartFoxServer_2X/SFS2X/www/jok/</Set>

  <Set name="virtualHosts">
    <Array type="java.lang.String">

Unfortunately it doesn't work: if I type the IP I still get the index.html of game 1. Any help would be greatly appreciated.



jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top