Redirect apache to tomcat

10,983

After long time this is tha answer:

    Edit file: /etc/apache2/sites-available/default
    ServerAdmin webmaster@localhost
    ServerName domain.com

    DocumentRoot /var/www
    ProxyPreserveHost on
    ProxyRequests off
    ProxyPass /phpmyadmin !
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

using ! to prevent forwarding phpadmin to tomcat

Share:
10,983
Alpha2k
Author by

Alpha2k

Updated on June 04, 2022

Comments

  • Alpha2k
    Alpha2k almost 2 years

    I am trying to redirect domain.com to tomcat7, I tried a lot of configurations and doesnt seem to work...

    This is my /etc/tomcat7/server.xml config

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443"
                proxyName="domain.com"
                proxyPort="80"
                />
    

    And this is my /etc/apache2/httpd.conf

    LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
    AddModule mod_proxy.c
    
    ProxyPass / http://domain.com:8080/
    ProxyPassReverse / http://domain.com:8080/
    
    <Location "/">
    Order allow,deny
    Allow from all
    </Location>
    

    When i go to domain.com i get this default apache message:

    It works!
    This is the default web page for this server.
    The web server software is running but no content has been added, yet.
    

    When i go to domain.com:8080 i get the tomcat message:

    It works !
    If you're seeing this page via a web browser, it means you've setup Tomcat successfully.     Congratulations!
    This is the default Tomcat home page. It can be found on the local filesystem at:     /var/lib/tomcat7/webapps/ROOT/index.html
    

    I loaded few .WAR with tomcat assistant one is called App1.
    If i go to domain.com/App1 i get:

    The requested URL /App1/ was not found on this server.
    

    But if i use domain.com:8080/App1 the app works properly and shows a for loop for example.

    UPDATE: tried /etc/apache2/ports.conf with this config:

    Listen 80
    ServerName domain.com
    DocumentRoot /var/www/domain.com/public_html
    NameVirtualHost IP
    

    UPDATE2: i just wiped out my debian and i just used /etc/apache2/httpd.conf to set this: (only with this file I achieved same result as above, still must use domain.com:8080/appname to run an app...)

    <VirtualHost *:8080>
    ProxyRequests off
    ProxyPreserveHost on
    ServerName domain.com
    ServerAlias *.domain.com
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    </VirtualHost> 
    

    How can I do it to redirect straight to tomcat default message instead of apaches ?
    And how to get rid of that :8080 and make apps work on domain.com/appname