1
votes

I have a vServer with debian 7.8 (wheezy), apache2 webserver and tomcat7.

I deployed a webapp with the apache www.mydomain.com/manager app into /var/lib/tomcat7/webapps/app/ which runs perfectly under www.mydomain.com:8080. It gets linked to my webapp´s welcome page www.mydomain.com:8080/app/#welcome.

My apache2 www.mydomain.com/host-manager lists only “localhost” under host name.

Now I want to connect my apache2 webserver to tomcat7, so that www.mydomain.com starts my webapp (like www.mydomain.com/#welcome).

Things, i have done so far:

  1. enabled proxy_http, which can be found under /etc/apache2/mods-enabled/proxy_http.load
  2. my /etc/apache2/sites-enabled/000-default file looks like

    <VirtualHost *:80> 
    ServerName www.mydomain.com 
    ServerAlias mydomain.com 
    ProxyRequest Off 
    ProxyPreserveHost On 
    
      <Proxy*> 
      Order deny,allow 
      Allow from all 
      </Proxy>
    
    ProxyPass / http://localhost:8080/ 
    ProxyPassReserve / http://localhost:8080/
    
    DocumentRoot /var/lib/tomcat7/webapps/app/ 
    </VirtualHost>
    
  3. changed /etc/hosts 127.0.0.1 localhost to 127.0.0.1 www.mydomain.com

  4. my /etc/tomcat7/server.xml looks like

    <Server port=”8005” shutdown=”SHUTDOWN”>
    ... 
    <Connector port=”8080” protocol=”HTTP/1.1”   
      ... 
      redirectPort=”8443”
      proxyPort=”80” 
      proxyName=”www.mydomain.com” />
    

What am i missing?

1
What is your error message? There is a space missing between ProxyPassReserve / and http://loclhost ...andpei
the missing space was a typo, edited it. I dont get any error...when surf to www.mydomain.com i get the standard apache2 site, www.mydomain.com:8080 gives me the standard tomcat site and www.mydomain.com:8080/app gives me my webapp-starting-pageFrank
you said, that you see the default apache2 site, just a guess: did you restart apache2 after your modification? without an error message its hard to find an error...andpei
With standard site i mean all those "it works" sites. i restarted both, apache2 and tomcat...and i found no error log because every service works just fine, but my proxy config must be wrong. Im pretty new to debian and vserver config, so can you tell me if there is any error log for a wrong proxy config?Frank

1 Answers

2
votes

From your configuration i noted:

  • whitespace at <_Proxy *> and </Proxy_>
  • DocumentRoot in combination with proxy configuration, doesn't make sense
  • if you plan to redirect to localhost:8080/app/ you have to configure this (see below)

I have no tomcat7, but i configured nginx: apache (80) --> proxy --> nginx (8080)

With the following configuration a subdirectoy app from nginx is displayed at port 80 via apache. I hope this will help to answer your question (just works fine with Debian 8):

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ProxyVia On
    ProxyRequests Off
    ProxyPreserveHost on

    ProxyPass / http://127.0.0.1:8080/app/ retry=0
    ProxyPassReverse / http://127.0.0.1:8080/app/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

enable proxy and restart apache:

a2enmod proxy
a2enmod proxy_http
service apache2 restart

all possible error messages are logged into /var/log/apache2/error.log, you should also take a look at your tomcat logfiles.

If you put the configuration in an other file than 000-default.conf you have to enable the site with a2ensite <sitename> so that apache knows that it exists.