Magento – Ubuntu 14.04 Apache + SSL server, how to configure Varnish

magento-1.9sslvarnish

I have a Magento running on a Ubuntu 14.04 server with Apache2 and SSL. I have installed Varnish but not sure how to set it up with SSL without using Nginx. this is my current vhost file ;

    <VirtualHost *:443>

ServerName mysite.com
ServerAlias www.mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite.com

<Directory /var/www/mysite.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

SSLEngine on
SSLCertificateFile /home/ssl/mysite_com.crt
SSLCertificateKeyFile /home/ssl/mysite.com.key
SSLCACertificateFile /home/ssl/mysite_com.ca-bundle

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
<VirtualHost *:80>
ServerName mysite.com
RewriteEngine On
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]
</VirtualHost>

Best Answer

You need to use Apache as a reverse proxy doing the SSL termination because Varnish doesn't support SSL. Try this:

Make sure proxy mod is enabled:

sudo a2enmod proxy

And in your Vhost

<VirtualHost *:443>
    ServerName app.mysite
    ServerAlias www.app.mysite
    SSLEngine On
    SSLCertificateFile    "/path/server.crt"
    SSLCertificateKeyFile "/path/server.key"
    <Location />
        SSLRequireSSL
    </Location>
    ProxyPreserveHost On
    ProxyPass / http://mysite:9023/
    ProxyPassReverse / http://mysite:9023/
</VirtualHost>

For more details follow this tutorial Apache SSL termiantion