<VirtualHost *:80>

    ServerAdmin admin@rosetta.platform

    #----------------------------------
    # Force https (except on localhost)
    #----------------------------------

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !=localhost
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
    ProxyPass / http://webapp:8080/
    ProxyPassReverse / http://webapp:8080/ 
       
</VirtualHost>


<VirtualHost *:443>
    ServerAdmin admin@rosetta.platform
    SSLEngine on
    SSLCertificateFile /root/certificates/rosetta_platform/rosetta_platform.crt
    SSLCertificateKeyFile /root/certificates/rosetta_platform/rosetta_platform.key
    SSLCACertificateFile /root/certificates/rosetta_platform/rosetta_platform.ca-bundle
    DocumentRoot /var/www/html
</VirtualHost>


<VirtualHost *:443>
    ServerAdmin admin@rosetta.platform
    ServerName ${ROSETTA_HOST}
    ProxyPass / http://webapp:8080/
    ProxyPassReverse / http://webapp:8080/

    SSLEngine on

    SSLCertificateFile /root/certificates/rosetta_platform/rosetta_platform.crt
    SSLCertificateKeyFile /root/certificates/rosetta_platform/rosetta_platform.key
    SSLCACertificateFile /root/certificates/rosetta_platform/rosetta_platform.ca-bundle

    # Browser-specific fixes
    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    # Required for the Open ID connect redirects to work properly
    RequestHeader set X-Forwarded-Proto 'https' env=HTTPS        

</VirtualHost>


