Containerized Ghost: Fixing the ‘Content Must Be Served Over HTTPS’ Mixed Content Error
A little bit of a background on how I ended up having this error:
Everything appeared to be working correctly at first. The site loaded over HTTPS without issues, but when accessing certain features — particularly the members portal — the browser began blocking requests due to a Mixed Content error. The page was served securely over HTTPS, but Ghost was attempting to request internal API resources over HTTP.
This resulted in me doing a network inspect inside google chrome and the following error showed up:
Mixed Content: The page at 'https://training-stack.com'
was loaded over HTTPS, but requested an insecure resource
'http://training-stack.com/members/api/member/'.
This request has been blocked; the content must be served over HTTPS.Why this happens?
Short answer:
Ghost generates URLs based on the configured site URL, not the proxy.
Long answer:
This usually happens when Ghost is running behind a reverse proxy that handles SSL (like Nginx or nginx-proxy). If the Ghost url configuration is set to http:// instead of https://, Ghost will generate internal API requests using HTTP, even though the public site is served over HTTPS.
Step 1 — Update Ghost URL inside the Docker-Compose, Dockerfile or Env.
GHOST_URL=https://yourdomain.comStep 2 — Ensure Ghost trusts the proxy:
server__trustProxy: "true"Step 3 — Recreate the container:
docker compose down
docker compose up -d --force-recreate ghostIssues like this are common when applications run behind reverse proxies. The key takeaway is that the application must know the public URL being used, even if SSL is handled externally.
Dictionary:
Reverse Proxy is a server that sits between the user and your application.
What's the use of it?
- To allow multiple services running in one server.
- Handling HTTPs
- Security and rate limiting
- Load Balancing