views:

16

answers:

2

Using an Apache virtualhost and mod_proxy I want to access a java application (myapp) available in a jetty instance on port 8080.

With ProxyPass / localhost:8080/ on my apache virtualhost configuration I can access the application running in jetty with www.mydomain.com/myapp but I want the application to be accessed from www.mydomain.com.

Trying with ProxyPass / localhost:8080/myapp The application cannot be found because the request becomes www.mydomain.com/myappmyapp/.

Then tried with:

<Location />
        ProxyPass localhost:8080/myapp/
        SetEnv force-proxy-request-1.0 1
        SetEnv proxy-nokeepalive 1
</Location>

I can access the application but just for the first request. Subsequent requests become www.mydomain.com/myappmyapp/

After reading many times wiki.eclipse.org/Jetty/Tutorial/Apache and the apache mod_proxy docs the only way I managed to use the application properly from www.mydomain.com is with the following configuration:

<Location /myapp/>
        ProxyPass localhost:8080/myapp/
        SetEnv force-proxy-request-1.0 1
        SetEnv proxy-nokeepalive 1
</Location>

<Location />
        ProxyPass localhost:8080/myapp/
        SetEnv force-proxy-request-1.0 1
        SetEnv proxy-nokeepalive 1
</Location>

so the request is forwarded to the jetty application in both cases.

I am quite new to apache and jetty and I am pretty sure there is a better and more elegant way of achieving the same result. In fact apache complains saying:

[warn] worker localhost:8080/myapp/ already used by another worker
A: 

If you want your webapp to be accessible at the root of your site, what you need is to deploy the web application into the root of container. Usually, this is done by calling the war file ROOT.war instead of myapp.war (although this ultimately depend on the configuration of your Jetty deployer, which may be more complex than the default).

Bruno
A: 

Yes it works from the jetty root, but I would like to have more than one application running. The configuration for myapp is under jetty's contexts folder:

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/mvc-showcase</Set>
  <Set name="war"><SystemProperty name="jetty.home"/>/webapps/mvc-showcase.war</Set>
</Configure>

my jetty version is 6.1.22

yellowtrolley