0

I have 3 wars set up on a Tomcat instance - these wars are being served at:

I have Apache on the same machine. I am trying to set Apache up so that I can access the 3 wars in the following way:

I have tried following the example Using Virtual_Host and mod_proxy together, but it is not working correctly. When I visit http://war1.mycompany.com/ the browser gets sent a 302 towards http://war1.mycompany.com/war1/ and that in return gives a 400 error.

If I visit http://war1.mycompany.com:9023/war1 (ie query Tomcat directly) then I get the site I am expecting, so the DNS is set up correctly, and the war is correctly deployed.

My Apache configuration file (/etc/httpd/conf.d/sites.conf) is as follows:

Listen 9024
<VirtualHost *:9024>
    ServerAdmin admin@mycompany.com
    ServerName war1.mycompany.com
    ErrorLog logs/error_log
    CustomLog logs/access_log common
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:9023/war1
    ProxyPassReverse / http://127.0.0.1:9023/war1
</VirtualHost>

I am using Apache 2.2.3 and Tomcat 6.0.14. Tomcat is configured pretty much normally:

<Host name="localhost"  appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
       prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>

The wars are in CATALINA_HOME/webapps/war1.war, etc.

What am I doing wrong? Is there something I should be looking for in the main Apache configuration?

Rich
  • 1,333
  • 5
  • 27
  • 39

1 Answers1

0

Quick edit: are you sure it's Apache giving you the error 400, btw? Use 'curl -v ' and examine the header traffic to ensure it's Apache that's 400'ing.

Hmmm, it looks right. Do you have a 'NameVirtualHost :9024" somewhere in your config? And, are you sure the mod_proxy modules are actually enabled via LoadModule somewhere?

Try using an alternate method:

<Location />
  ProxyRequests Off
  ProxyPreserveHost On
  ProxyPass http://127.0.0.1:9023/war1
  ProxyPassReverse http://127.0.0.1:9023/war1
  #
  # Perhaps your Tomcat is HTTP/1.1 buggy?
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1
</Location>

I suggest setting your 'LogLevel debug' to examine the actual traffic to determine what's going wrong.