Hello again, Joakim your suggestion of preventing people to access the files through the IP is very interesting and I intend to do that in the end. I must clarify that for now, I'm only using the IP as a way of testing a temporary virtual hosts configuration. The problem is I can't get jetty to recognize the context xml file in the webapps directory. Maybe the syntax of that file is incorrect. Browsing to http://1.2.3.4/ or http://1.2.3.4/index.html gives me the index.html of the "root" game (www/root/) but what I want is the one from the "jok" (www/jok/) game. The only way I could make the context file work (at least partially) is by placing it in the www/jok/WEB-INF directory. Browsing to http://1.2.3.4/index.html then returns the index of the jok game. This is good. I expected it to do the same with http://1.2.3.4 but it throws error http 500 : java.lang.NullPointerException. Smartfoxserver's runtime log has the full trace: java.lang.NullPointerException at org.eclipse.jetty.server.handler.ResourceHandler.handle(ResourceHandler.java:439) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1112) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:459) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232) at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) at java.lang.Thread.run(Unknown Source) At this moment I don't have anything left in the webapps directory. I have a jetty-web.xml file located at /home/fo/SmartFoxServer_2X/SFS2X/www/jok/WEB-INF alongside a web.xml. The jetty-web.xml contains: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- Required minimal context configuration : --> <!-- + contextPath --> <!-- + war OR resourceBase --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <Set name="contextPath">/</Set> <Set name="resourceBase">/home/fo/SmartFoxServer_2X/SFS2X/www/jok</Set> <Set name="handler"> <New class="org.eclipse.jetty.server.handler.ResourceHandler"> <Set name="welcomeFiles"> <Array type="String"> <Item>index.html</Item> </Array> </Set> </New> </Set> <!-- virtual hosts --> <Set name="virtualHosts"> <Array type="String"> <Item>1.2.3.4</Item> </Array> </Set> </Configure> Why does http://1.2.3.4 generate error 500 while http://1.2.3.4/index.html displays the page properly? Thank you again for your help :-) Frank From: [email protected] To: [email protected] Date: Fri, 17 Oct 2014 21:17:03 -0400 Subject: 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: [email protected] To: [email protected] Subject: Re: [jetty-users] virtual hosts jetty v9 Virtual Hosts configuration has 2 matching modes.The "Host:" request header. 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.4A connector on that IP, port 8080There are 2 hostnames for that IPjok.company.cominternal.company.com 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.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 <[email protected]>webtide.com - intalio.com/jettyExpert advice, services and support from from the Jetty & CometD expertseclipse.org/jetty - cometd.org On Fri, Oct 17, 2014 at 4:20 PM, Jokrummy Pointcom <[email protected]> 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
