Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with my Apache and Tomcat configuration. I have an Apache instance as a proxy to Tomcat. The Tomcat serves two virtual hosts. The problem occurs when one Apache virtual points to particular virtual in Tomcat. I can show in on my config files:

/etc/hosts:       localhost       my-pages


<VirtualHost *:80>
        RewriteEngine on
        ServerAdmin webmaster@my-pages.tld
        ServerAlias my-pages.tld
        ProxyPass / http://my-pages:9082/
        ProxyPassReverse / http://my-pages:9082/
        # Logs
        ErrorLog /usr/local/tomcat2/logs/error.log
        CustomLog /usr/local/tomcat2/logs/access.log common
        LogLevel debug

<Proxy *>
  Order deny,allow
  Allow from all
  Deny from all

ProxyRequests       Off
ProxyPreserveHost   Off


<Connector port="8081" protocol="HTTP/1.1"
               URIEncoding="UTF-8" />
<Connector port="9082" proxyPort="80" proxyName="my-pages" />

<Host name="my-pages" appBase="my-pages"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      <Context path="" docBase="envelon-web" />
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
             prefix="my-pages_access_" suffix=".log" pattern="common" resolveHosts="false"/>

When I run this configuration the pages points to the default virtual host in Tomcat (not to the "my-pages" virtual). It is quite strange, because when I set the same configuration on my local machine (not on server), it works fine. Also when I use domain name in the Tomcat virtual (my-pages.tld instead of my-pages) it also works (I don't want to use this config. cause I want to "hide" Tomcat from outside).

Do you know where I'm wrong or what will fix this problem? Thanks for any response!


share|improve this question

I finally solved this problem. The problem was that the ProxyPreserveHost was defined outside the directive. There were defined more virtual host in the Apache and some of them had *ProxyPreserveHost On" what influenced other hosts.

I moved ProxyPreserveHost into the what solved the

share|improve this answer

Generally speaking, there are two solutions:

  1. ProxyPreserveHost with mod_proxy_http
  2. mod_proxy_ajp

Either works fine for virtual hosts and which to choose is a matter of preference or other requirements beyond what was asked here.

share|improve this answer

Your Answer


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.