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

> A request on http://jok.company.com/index.html would be against Host "jok.company.com"
> A request on http://internal.company.com/index.html would be against Host "internal.company.com"
> A request on https://jok.company.com:8443/index.html would be against Host "jok.company.com:8443"

> Set the virtualHost configurations to those names.

I must set it in this block? can you give me the syntax please?

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

Many thanks


Date: Fri, 17 Oct 2014 17:37:29 -0700
From: joakim@xxxxxxxxxxx
To: jetty-users@xxxxxxxxxxx
Subject: 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 1.2.3.4
A connector on that IP, port 8080
There are 2 hostnames for that IP

A request on http://jok.company.com/index.html would be against Host "jok.company.com"

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 http://1.2.3.4/index.html, 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

/home/fo/SmartFoxServer_2X/SFS2X/lib/jetty/webapps

The file contains:

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

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
 
<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">
      <Item>1.2.3.4</Item>
    </Array>
  </Set>
</Configure>

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.

Regards,

Frank

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________ jetty-users mailing list jetty-users@xxxxxxxxxxx To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users

Back to the top