tomcatmod-jk

Unable to integrate Tomcat with Apache HTTP Server


I have followed several tutorials on how to integrate Appache HTTP Server with Tomcat but the tomcat servers just do not load. I am doing this on a Ubuntu 20.04.1

I can load up the site http://myurl.com:8080/examples. However, when I call https://myurl.com/examples/ I get Not Found error stating:

The requested URL was not found on this server. Apache/2.4.41(Ubuntu) Server at myurl.com port 443

I thought https://myurl.com/examples should work.

My set up in /opt/tomcat/conf includes server.xml and a line for AJP 1.3 connector as follows

<Connector protocol="AJP/1.3" port="8009" secretRequired="false" redirectPort="8443" enableLookups="false" />

My /opt/tomcat/conf/tomcat-users.xml includes an entry admin-gui

The firewall allows Apache and port 8080 (among others)

My /etc/systemd/system/tomcat.service is as follows

Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64/
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -      Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

My /etc/apache2/workers.properties is as follows

# Define 1 real worker using ajp13
worker.list=worker1

#set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
# configure jk-status
worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true
# configure jk-manager
worker.list=jk-manager
worker.jk-manager.type=status

it is referenced from /etc/apache2/mods-available/jk.conf as JkWorkersFile /etc/apache2/workers.properties

At /etc/apache2/sites-enabled/000-default.conf I have <VirtualHost *:80> DocumentRoot /var/www/html JKMount /* worker1 </VirtualHost>

Tomcat status is running (Active)

What am I missing?


Solution

  • You have only provided the JKMount for the http virtual host. You need to add JkMountCopy On in the https virtual host (or equivalent).

    JKMounts are not copied between virtual hosts by default.