Thursday 15 September 2011

proxy - Basic configuration to point a domain to a web application running on Jetty at port 8080 -



proxy - Basic configuration to point a domain to a web application running on Jetty at port 8080 -

my current setup simple.

i have webserver static ip running ubuntu. have domain points static ip correctly. on server have jetty instance running standard / default configuration - more - etc/jetty-logging.xml , etc/jetty.xml configurations. jetty listens on default port 8080.

in webapps folder have 2 extracted web applications, no war files.

my web applications accessible follows:

http://1.2.3.4:8080/web_app_1 , http://1.2.3.4:8080/web_app_2 http://www.example.com:8080/web_app_1 , http://www.example.com:8080/web_app_2

what trying accomplish imagine quite simple experience limited.

i serve 1 web application @ http://www.example.com , other @ http://admin.example.com. more specifically:

http://www.example.com -> http://1.2.3.4:8080/web_app_1 http://admin.example.com -> http://1.2.3.4:8080/web_app_2

what simplest , best way accomplish this?

i prefer not configure jetty port 80 or have run root.

this "think" know far...

i imagine need somehow forwards traffic port 80 port 8080 internally on webserver - have no thought how in simplest possible way - don't have much configuration knowledge of apache or nginex before go ahead , utilize 1 of them know next right route. know 1 can utilize iptables route seems bit hidden , obscure me.

i think need create utilize of jetty's virtual hosts configuration looks (taken https://wiki.eclipse.org/jetty/howto/configure_virtual_hosts):

<configure class="org.eclipse.jetty.webapp.webappcontext"> <set name="war"><systemproperty name="jetty.home"/>/webapps/xxx.war</set> <set name="contextpath">/</set> <set name="virtualhosts"> <array type="java.lang.string"> <item>333.444.555.666</item> <item>127.0.0.1</item> <item>www.blah.com</item> <item>www.blah.net</item> <item>www.blah.org</item> </array> </set> </configure> <configure class="org.eclipse.jetty.webapp.webappcontext"> <set name="war"><systemproperty name="jetty.home"/>/webapps/zzz.war</set> <set name="contextpath">/</set> <set name="virtualhosts"> <array type="java.lang.string"> <item>777.888.888.111</item> <item>www.other.com</item> <item>www.other.net</item> <item>www.other.org</item> </array> </set> </configure>

unlike illustration above not have deployed war file , unable find how configure web app directory instead configuration.

any help or force in right direction appreciated!

thanks!

xandel

so went iptables route...

the configuration ended beingness extremely simple. per jetty documentation (http://www.eclipse.org/jetty/documentation/current/setting-port80-access.html) configured iptables next command:

/sbin/iptables -t nat -i prerouting -p tcp --dport 80 -j redirect --to-port 8080

i created new xml configuration file jetty looks follows:

<?xml version="1.0"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <configure id="contexts" class="org.eclipse.jetty.server.handler.contexthandlercollection"> <call name="addhandler"> <arg> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/</set> <set name="extractwar">false</set> <set name="copywebdir">false</set> <set name="resourcebase"><systemproperty name="jetty.home" default="."/>/webapps/web_app_2/</set> <set name="virtualhosts"> <array type="java.lang.string"> <item>admin.example.com</item> </array> </set> </new> </arg> </call> <call name="addhandler"> <arg> <new class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/</set> <set name="extractwar">false</set> <set name="copywebdir">false</set> <set name="resourcebase"><systemproperty name="jetty.home" default="."/>/webapps/web_app_1/</set> <set name="virtualhosts"> <array type="java.lang.string"> <item>www.example.com</item> <item>example.com</item> </array> </set> </new> </arg> </call> </configure>

i hope helps!

xandel

proxy dns jetty subdomain jetty-9

No comments:

Post a Comment