How can I use a virtual host to redirect https subfolders to different ports in apache?
This did it:
<VirtualHost *:443>
ServerName mydomain.com
ServerAlias secure.mydomain.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine On
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
SSLCACertificateFile /etc/apache2/ssl/ca.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /myapp/ http://127.0.0.1:8112/
<Location /myapp/>
ProxyPassReverse /
ProxyPassReverseCookiePath / /myapp/
#Some web services may or may not require an additional specific header variable
# or additional internal configuration settings when located at a subfolder
#In my case for example myapp specifically required a header variable to be set
# with the new subfolder base as follows
RequestHeader set X-myapp-Base "/myapp/"
Order allow,deny
Allow from all
</Location>
</VirtualHost>
In this solution the web service will react as though it's responding on http and the apache reverse proxy will handle the ssl so that the service will appear as https to the user.
This may break some services or websites that are http/https aware. Wordpress for example would require the X-forwarded-for variable to be added to the header in a similar way to the example above.