Search code examples
ssltomcat7reverse-proxyapache2.4

Using Apache 2.4 on Ubuntu 16 to reverse proxy Tomcat 7: webapp not found


I am using the instructions on this page to use Apache, using SSL, in front of a Tomcat 7 instance, that is not using SSL, and which has one webapp deployed.

I have followed all of the instructions and am able to navigate to:

http://localhost
https://localhost
http://localhost/my-webapp

The only thing that is not working is

https://localhost/my-webapp

It returns a 404 Not found error.

I have posted below the pertinent parts of my conf files.

Apache 000-default.conf

<VirtualHost *:80>
  ...
  ProxyPass /my-webapp ajp://localhost:8009/my-webapp
  ProxyPassReverse /my-webapp ajp://localhost:8009/my-webapp
</VirtualHost>

Apache default-ssl.conf

<VirtualHost _default_:443>
  ...
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
  SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
</VirtualHost>

Tomcat server.xml

  ...
  <Server port="8005" shutdown="SHUTDOWN">
    ...
    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" />

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

I have all the mods enabled, and both ssl and proxy seem to be working. When I navigate to

  http://localhost/my-webapp

without https, the proxy works fine. And when I navigate to

  https://localhost

it also works; it returns the static Apache page. (It complains about the self-signed certificates not being secure but otherwise, it works ...)

Shouldn't

  https://localhost/my-webapp

also work? What am I missing?


Solution

  • You need to define the proxy inside virtualhots_443

      ProxyPass /my-webapp ajp://localhost:8009/my-webapp
    ProxyPassReverse /my-webapp ajp://localhost:8009/my-webapp