Changing url to https in config file causes ERR_TOO_MANY_REDIRECTS

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

And

  • How was Ghost installed and configured?
    ghost install
  • What Node version, database, OS & browser are you using?
    Node version is v16.20.0, database is mysql5, OS is Ubuntu, browser is Chrome
  • What errors or information do you see in the console?
    ERR_TOO_MANY_REDIRECTS
  • What steps could someone else take to reproduce the issue you’re having?
    set url parameter in config.production.json to https

Sorry for making another topic on this issue, but none of the solutions from the other topics has worked for me.
Because my blog was loading certain images via http instead of https, I have changed my url to this: "url": "https://usa.pingpongx.com/us/blog/" This resulted in an ERR_TOO_MANY_REDIRECTS error when I try to access the blog on browser (currently I changed it back to http for troubleshooting purposes).

This is my nginx config file:

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

    server_name usa.pingpongx.com;
    root /data/ghost/www/site-US/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location ^~ /us/blog {
        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;
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect off;
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

This is my ghost config file:

{
  "url": "https://usa.pingpongx.com/us/blog/",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "username",
      "password": "password",
      "database": "us_db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/data/ghost/www/site-US/content"
  }
}

I’ve spent many hours on this with no result :( Advice will be deeply appreciated!

A little update: I tried to directly edit the html element of an image from my browser, and the image loaded correctly once I changed all the http to https. Suggestions on how I can serve the images over https without causing the too many redirect error will be a real lifesaver :smiling_face_with_tear:

You could edit the image links themselves using gctools. GitHub - TryGhost/gctools: Command line utilities for working with Ghost content

But it seems likely there’s an Nginx solution possible.

Your Nginx config isn’t setup for SSL (and your site is running on port 80 at present.)

When switching to SSL (https) you need to change production.config.json, and also run Ghost setup: ghost setup ssl.

Note: if you’re behind Cloudflare, place it into development mode during setup.