HTTP/HTTPS config - too many redirects

OS: Ubuntu 18.04
Ghost-CLI version: 1.17.1
Ghost version: 5.9.4
Node: v14.20.0

I’ve recently been having trouble with broken images when uploading these via the ‘New Post’ page and have tracked this to a potential config error for HTTP/HTTPS…

My config.production.json file currently has the URL set as

When amending this to, this causes a ‘Too Many Redirects’ error

My conf file in /var/www/ghost/system/files is as below:

server {
    listen 80;
    listen [::]:80;

    root /var/www/ghost/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;


    location ~ /.well-known {
        allow all;

SSL/TLS config in Cloudflare is set to Flexible and I have tried amending this to Full (Strict), however, this then stops all traffic getting through.

A mixed content message is also shown in the console:

The page at ‘hxxps://’ was loaded over HTTPS, but requested an insecure resource ‘hxxp://’. This request has been blocked; the content must be served over HTTPS.

Appreciate any advice on best practice to reconfigure this, many thanks.

Bumping this to advise that adding the following code into my /var/www/ghost/system/files/site.conf has seemed to resolve this issue:

server {
   if ($**http_x_forwarded_proto** = "http") {
     return 301 https://$server_name$request_uri;
1 Like