I'm trying to put an Apache server in front of a Tomcat server.
Apache's documentation states regarding the ProxyPreserveHost
option: When enabled, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line.
I built a simple scenario. I setup a virtual host in Apache and set ServerName
and ServerAlias
. I also set ProxyPreserveHost Off
. The forwarding of the request is initiated by ProxyPass / ajp://tomcat001:8009/
Tomcat's server.xml
has a line host name="tomcat001"
. When I now call tomcat001 - what happens to be set as ServerName
- in the browser everything works nicely.
When I call tomcat001a
- the host that is set as ServerAlias - Tomcat informs be the called file does not exist under /ROOT
- meaning it calls Tomcat's default site.
I now wonder what the Apache documentation means by hostname specified in the ProxyPass line
? Don't they mean the target site? I expect the tomcat host provided there to be called, under what hostname it might have ever reached Apache.
Addition: 20161023
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/Webs/tomcat001"
ServerName tomcat001
ServerAlias tomcat001a
LogLevel debug rewrite:trace3
<Directory "D:/Webs/tomcat001">
AllowOverride All
Require all granted
DirectoryIndex index.cfm
OPTIONS +indexes
</Directory>
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / ajp://tomcat001:8009/
ProxyPassReverse / http://tomcat001:8009/
</VirtualHost>
server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="tomcat001" appBase="webapps" autoDeploy="true" unpackWARs="true">
<Context path="" docBase="D:/Webs/tomcat001">
<JarScanner scanClassPath="false"/>
</Context>
</Host>