Search code examples
apachehttp-redirectproxytomcat7forward

Redirect specific sites to tomcat7 from apache


Before going on, let me say that I'm rather new to application protocols and do not fully understand how this world works ... :-)

This is the situation:

  1. I have several sites being served by apache2.4.7 and those work well when accessing apache on port 80.
  2. On the other hand, I have only one site being served by tomcat7 and it's also working well when accessing Tomcat on port 8080.
  3. I tried to redirect traffic from apache on port 80 to that specific site on tomcat on port 8080 and cannot do it (getting a 404 error message).
  4. I have also enabled the proxy and proxy_http modules, but nothing changed

This is the sites-enabled file for apache:

<VirtualHost 10.10.61.10:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www
        ServerName 10.10.61.10

        <Directory />
                Options None
                AllowOverride None
        </Directory>

        Alias /racktables /var/www/racktables/wwwroot/
        <Directory /var/www/racktables/wwwroot>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost 10.10.61.10:80>
        ProxyPreserveHost On
        ProxyRequests Off
        ProxyPass /app1/ http://10.10.61.10:8080/app1/
        ProxyPassReverse /app1/ http://10.10.61.10:8080/app1/
</VirtualHost>

All the information that I have read only mentioned that adding the above configuration regarding the proxy* parameters nothing more, nothing less.

However, when looking at the access.log of apache, I get the following:

10.10.61.62 - - [10/Nov/2015:11:32:00 -0300] "GET /app1 HTTP/1.1" 404 410 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"

What is it that I'm missing? Any ideas or hints?

Thanks!

Lucas


Solution

  • Well, after some digging, the solution was to include everything under the same virtualhost such as this:

    <VirtualHost 10.10.61.10:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www
            ServerName 10.10.61.10
    
            <Directory />
                    Options None
                    AllowOverride None
            </Directory>
    
            Alias /racktables /var/www/racktables/wwwroot/
            <Directory /var/www/racktables/wwwroot>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
            </Directory>
    
            ProxyPreserveHost On
            ProxyRequests Off
            ProxyPass /app1/ http://10.10.61.10:8080/app1/
            ProxyPassReverse /app1/ http://10.10.61.10:8080/app1/
    
    </VirtualHost>
    

    Regards!

    Lucas