Enable https behind loadbalancers for Contao CMS

Recently I had the pleasure to setup Contao (https://contao.org/) in the Amazon cloud (AWS – Elastic Beanstalk). Therefore I had to enable HTTPS behind loadbalancersThe problem was, that the AWS-Loadbalancer is the SSL Endpoint / SSL Terminator in an AWS Beanstalk – architecture.

Enable https behind loadbalancers

Contao didn’t recognize, that it was running under HTTPS and therefore set the wrong base-tag href protocol although the following HTTP-headers where sent by the loadbalancer when delegating the request to the finely responding Apache Webserver:


Despite I’d called the page via HTTPS and had installed a valid SSL-certificate, I got SSL warnings, when calling the application in a browser.

I found the solution on Stack Overflow (answer from fritzmg) and added the mentioned lines to my CONTAOROOT/system/config/initconfig.php:


// Put your custom configuration here
// @see http://stackoverflow.com/questions/36773112/contao-how-can-i-change-the-protocol-of-the-base-url
# enable SSL through
    $_SERVER['HTTPS'] = 1;

That finely solved my problem and the base tag was generated correctly.


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.