1

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:

127.0.0.1       localhost
127.0.0.1       my-pages

/etc/apache/sites-enabled/my-pages.tld:

<VirtualHost *:80>
        RewriteEngine on
        ServerAdmin [email protected]
        ServerName www.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
</VirtualHost>

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

ProxyRequests       Off
ProxyPreserveHost   Off

${CATALINA_HOME}/conf/server.xml

...
<Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444"
               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"/>
</Host>

When I run this configuration the www.my-pages.tld 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!

Mateo

2 Answers 2

1

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

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .