Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.