0
votes

I have a Tomcat application running at context "/mycontext". Apache 2.4.6 is handling the front end via a proxy in httpd.conf. I am unable to render pages at /mycontext using https with CA signed certificate.

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias *.example.com
  ProxyRequests off
  ProxyPass         /mycontext  http://example.com:8081/mycontext
  ProxyPassReverse  /mycontext  http://example.com:8081/mycontext
</VirtualHost>

Requests sent as http://example.com/mycontext are rendered as expected.

For certain pages at /mycontext we want to use SSL to connect. Example: https://example.com/mycontext/transaction.xhtml using a CA signed certificate.

For https:

<VirtualHost *:443>
  ProxyRequests off
  ProxyPreserveHost on
  SSLEngine on
  SSLCertificateFile /path/to/certs/ca.crt
  SSLCertificateKeyFile /path/to/key/private/mykey.key
  ServerName www.example.com
  ServerAlias *.example.com
  ProxyPass /mycontext http://example.com:8081/mycontext
  ProxyPassReverse /mycontext http://example.com:8081/mycontext
</VirtualHost>

My Tomcat connector in server.xml:

 <Connector port="8081" protocol="HTTP/1.1"
        connectionTimeout="20000"
        proxyName="www.example.com"
        proxyPort="80"
        redirectPort="8443"
        xpoweredBy="false"
        server="Apache TomEE" />

*Edit - Since I couldn't get the proxy to redirect to the Connector at port 8081, I defined a second Connector using port 8082 with the proxyPort=443 in Tomcat's server.xml. Still no success.

    <Connector port="8082" protocol="HTTP/1.1"
    connectionTimeout="20000"
    proxyName="www.example.com"
    proxyPort="443"
    redirectPort="8443"
    xpoweredBy="false"
    server="Apache TomEE" />

Requests to https://example.com/mycontext result in Apache responding:

Not Found

The requested URL /mycontext/ was not found on this server.

Is this a missing or incorrectly set virtual host directive problem? The SSL cert is correctly installed showing the lock icon the "Verified by ....".

1

1 Answers

0
votes

The SSL virtualhost is not proxying correctly, and you must match slashes or the lack of them. So you must use:

ProxyPass /mycontext http://example.com:8081/mycontext

This is what you are using in the non-SSL virtualhost, not sure why you changed it in the SSL virtualhost since as you describe you want to do the same thing.