Freitag, 20. Januar 2012

Tomcat application at port 80

If you always wanted to slim down your JSP / Tomcat application path ...

Before:
http://yourdomain:8080/yourApplicationName/(index.jsp)

After:
http://yourdomain/(index.jsp)

1. get rid of yourApplicationName
in /yourTomcatPath/webapps/ there should be a ROOT folder next to yourApplicationName, just copy the content of yourApplicationName into ROOT, of course this only makes sense if you got only one application on your server

2. get rid of the port
install an apache as reverse proxy
# apt-get install apache2
# a2enmod proxy proxy_http
# nano /etc/apache2/sites-enabled/000-default

clear out everything and insert the following (in nano use Ctrl+k to delete single lines)

<Virtualhost *:80="">
        ServerAdmin webmaster@localhost

        ProxyRequests Off

        HostnameLookups Off
        UseCanonicalName On

        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http://127.0.0.1:8080/


        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "="" doc="" share="" usr="">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</Virtualhost>


after that restart your apache by
# /etc/init.d/apache2 restart
your tomcat defaults to start on port 8080, so your good to go.

Don't ask me for any modifications ... look here for further detail
http://www.apachetutor.org/admin/reverseproxies
http://www.linux-club.de/viewtopic.php?f=22&t=105707