Link to home
Start Free TrialLog in
Avatar of mobot
mobotFlag for United States of America

asked on

Running Apache Tomcat and Apache HTTPD on port 80 simultaneously.

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.
Avatar of David Favor
David Favor
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mobot

ASKER

@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?
Avatar of mobot

ASKER

@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.
//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?
Avatar of mobot

ASKER

@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.
Avatar of mobot

ASKER

Thank you.