Ghost doesn't load images

Problem

Ghost is fantastic, as soon as I met it I was a fan of it, even more because it's open source, but one of my first difficulties was loading images when using https.

Failed to load images on Ghost blog

Main cause

Investigating I discovered that this happens when using https but the images are loaded in http.

Images are being loaded over http instead of https

Solution

To resolve this issue, some adjustments had to be made.  The first one is to change the container parameter url from http to https:

docker run -d --name ghost --hostname ghost -v /iop/data/ghost:/var/lib/ghost/content -e url=https://lucaspolloni.xyz -p 3001:2368 ghost

It will be necessary to review the apache settings, first of all activate the module headers:

a2enmod headers

Then add the request header X-Forwarded-Proto in the apache vhost:

<IfModule mod_ssl.c>
<VirtualHost *:443>
	...
	RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
	...
</VirtualHost>
</IfModule>

/etc/apache2/sites-available/lucaspolloni-le-ssl.conf

Restart apache service:

systemctl restart apache2

Now it's time to test:

Problem solved!