Running Apache Tomcat and Apache HTTPD on port 80 simultaneously.

mobot
mobot used Ask the Experts™
on
I want http://server.mydomain.org to take me straight to the java app.
What do I need to do to make that happen?

http://server.mydomain.org takes me to the Tomcat GUI.
http://server.mydomain.org/javaapp takes me to the java app.

i'm using this conf file.  It's the only site enabled.
<VirtualHost server.mydomain.org>
ServerName server.mydomain.org
ServerAlias server.mydomain.org
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://server.mydomain.org:8080/
ProxyPassReverse / http://server.mydomain.org:8080/
</VirtualHost>


The usual stuff. This is not enabled.
000-default
<VirtualHost *80>
#ServerName www.example.com  commented out.
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR]/error.log
CustomLog $[APACHE_LOG_DIR]/access.log combined
</VirtualHOst>

#vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Java 1.8.0
Tomcat 9.0.12
Apache 2.4
Debian 9.5

I have read doc's from Apache, and several from Digital Ocean, and others.
I just don't get it.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Normally what you're asking is setup by default.

Tomcat normally runs on port 127.0.0.1:8080 or some other port and Java Servlet requests are proxied from Apache to Tomcat for handling... so... any HTML file requests serve normally from Apache + any Java file requests are proxied to Tomcat.

Tip: Trying to get all this working from scratch, especially Apache + Tomcat or adding other language support like PHP on top... well.. complex...

Simple way to do this is to start with a Distro which handles all this setup complexity in packaging.

Ubuntu Bionic tends to produce a working Tomcat system by simply installing packages. No mucking about with config files.
IT Business Systems Analyst / Software Developer
Top Expert 2015
Commented:
http://server.mydomain.org takes me to the Tomcat GUI.
http://server.mydomain.org/javaapp takes me to the java app.

If the above is actually working as you say, then I think you are almost there. You just need to get Tomcat to serve the app without the "javaapp" part of the path. There are (at least) a couple of ways to do this, but probably the easiest is to just move the webapp. So wherever your webapp is currently located, it may be in a directory such as ...

/var/lib/tomcat/webapps/javaapp

Just move everything inside that directory (and subdirectories) into the "ROOT" directory next to the "javaapp" directory, so in the example directory I gave above, it should be...

/var/lib/tomcat/webapps/ROOT

(The ROOT directory is just another webapp but one that gets served at the root path "/" rather than a named path)

Author

Commented:
@mccarl

My path /opt/tomcat/webapps/javaapp.
I moved /opt/tomcat/webapps/javaapp to /opt/tomcat/webapps/ROOT.
//server.mydomain.org still resolves to the Tomcat GUI
//server.mydomain.org/javaapp throws a 404 error since I moved the javaapp into ROOT.
I added DocumentRoot /opt/tomcat/webapps/ROOT to the VirtualHost conf file.
That didn't work, it still throws the 404 error.
Suggestions???

And thanks for explaining how ROOT works.  
My java app is named xxx-2.3.5.  Would the characters - . being included in the name cause me grief?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Author

Commented:
@David

Thanks for cluing me in on that tip.  I didn't know about it.  I'm still pursuing my current approach.  I want to learn how it's done this way.
mccarlIT Business Systems Analyst / Software Developer
Top Expert 2015

Commented:
//server.mydomain.org still resolves to the Tomcat GUI

Sorry, probably should have mentioned... maybe the ROOT folder still has existing files (such as index.html, etc) that are being picked up as the "welcome page" before whatever you have set up for you java app. Trying removing (or just moving) as such files out of ROOT that aren't part of you app.

If this still doesn't work, are you happy to post some files? Probably need to look at you Apache conf files, Tomcat server.xml, context.xml, web.xml, and maybe a directory listing of you web app?

Author

Commented:
@mccarl - i'm still digging at this as I get time.  right now i'm still getting the 404. there was an index.jsp in the ROOT dir.  I moved it to a bakup folder. but no joy. thanks again.

Author

Commented:
Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial