Preventing https redirect for internal communications

I have ghost hosted inside a docker-compose stack with an nginx proxy set up to forward a portion of the content to a web app and a portion to ghost. In production, nginx provides the HTTP to HTTPS redirect so ghost doesn’t have to.

I have an API hosted on the web-app side (in a separate container) that is querying Ghost for information. I want it to communicate internally across the docker network, so it calls into http://ghost:2368/(etc.) In development, when ghost is hosted on http, this works great. In production, when I’m on https, Ghost tries to be smart and redirect that http call to https, which doesn’t work.

Tl;dr: Is there a way to stop ghost redirecting http traffic when the site url is set to https, so that the two docker containers can communicate?

Try adding an x-forwarded-proto: https header when making the request between containers. This is how nginx should be configured to let Ghost know that the connection was made securely, but since you’re doing container-container calls, this is an alternative.

Thanks @vikaspotluri123 !

Is there any way to add this header when using the JavaScript content SDK? It looks like it doesn’t accept any custom headers, but maybe I can patch the axios call?

To answer my own question, adding the following to the top of my script fixed the issue:

axios.defaults.headers.common = {
    "X-Forwarded-Proto": "https",