Search code examples
phpapachesslhttpsproxypass

Default SSL and ProxyPass redirect to another domains (on another computer) with it's own SSL


The question is is it possible to do following on Ubuntu with apache2, ProxyPass and SSL enabled:

  1. I have main server, let's say it's domain is http://domain.com - working OK

  2. I have SSL enabled with certificate for domain.com and www.domain.com and https://domain.com is working OK

  3. By default, I have 2 conf files in /etc/apache2/sites-enabled - 000-default handling the *.80 virtual hosts and default-ssl handling the *.443 virtual hosts. In this second file I have specified all certificate files for domain.com

  4. In 000-default I have ProxyPass set redirectiong to server handling the domain subdomain.domain.com on local computer 192.168.0.100 - working OK

  5. I have certificates installed on 192.168.0.100 for subdomain.domain.com. If I point my browser to https://subdomain.domain.com it gives warning, because it loads the certificate for domain.com.

How to make so, that the request for https://subdomain.domain.com to be transfered to 192.168.0.100 and load it's files (for https://subdomain.domain.com)?


Solution

  • Here is my working code

    <VirtualHost *:443>
      ServerName subdomain.domain.com
      ServerAdmin admin@domain.com
    
      SSLEngine On
      SSLCertificateKeyFile /etc/ssl/private/subdomain.key
      SSLCertificateFile    /etc/ssl/certs/subdomain.crt
      SSLCertificateChainFile /etc/ssl/server.ca.pem
      SSLCACertificateFile /etc/ssl/ca.pem
    
      BrowserMatch ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    
      LogLevel warn
      CustomLog /var/log/apache2/access.log combined
      ErrorLog /var/log/apache2/error.log
    
      SSLProxyEngine On
      ProxyPreserveHost On
      ProxyRequests Off
      ProxyPass / https://192.168.0.100/
      ProxyPassReverse / https://192.168.0.100/
    
      php_flag display_errors on
      php_value error_reporting 7
    </VirtualHost>