Image showing in draft but not in preview or published: not all links are HTTPS

When editing, all the images are showing however when I go to preview or publish only the Videos and article image show. The rest are all broken links

If I right-click on the broken link and choose open image in new tab, it opens (https://www.southernhikes.co.nz/content/images/size/w1000/2024/03/20240222_132427-3.jpg)

The code looks as follows:

<figure class="kg-card kg-image-card"><img src="https://www.southernhikes.co.nz/content/images/2024/03/here-to-there.jpg" class="kg-image" alt="" loading="lazy" width="2000" height="924" srcset="http://www.southernhikes.co.nz/content/images/size/w600/2024/03/here-to-there.jpg 600w, http://www.southernhikes.co.nz/content/images/size/w1000/2024/03/here-to-there.jpg 1000w, http://www.southernhikes.co.nz/content/images/size/w1600/2024/03/here-to-there.jpg 1600w, http://www.southernhikes.co.nz/content/images/2024/03/here-to-there.jpg 2000w" sizes="(min-width: 720px) 720px"></figure>
1 Like

Worked out the cause but need to still figure out how to fix it.

It has do do with my reverse proxy and maybe also with my cloudflare settings.

Will look at it over the next few days and update once sorted.

1 Like

So the issue is that when you look at the HTML, the image is via HTTP and not HTTPS which is required by the site and hence the image on the page does not show. Where do I set things so that all site content referenced in the HTLP has HTTPS links?

1 Like

I tried

ghost config url https://myurl.com

but that made no difference.

1 Like

Did you restart Ghost after setting the URL?

1 Like

Yes. I have done a new install now: This link shows what is happening: https://www.southernhikes.co.nz/test/

I might need to start again. It has something to do with nginx and cloudflare I think. This is the only site this is happening to for me though.

I have set the url back to HTTPS, SSL is not installed on ghost as I am letting NGINX Proxy Manager look after that for me.

It looks like Ghost is still not properly configured. The config is showing the site URL with http.

curl --silent https://www.southernhikes.co.nz/ghost/api/admin/site/  | jq .site.url
"http://www.southernhikes.co.nz/"

Ok so I have done the following:

ghost config url https://www.southernhikes.co.nz

but when I try running setup ssl, I get

Message: Command failed: /bin/sh -c sudo -S -p '#node-sudo-passwd#'  /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --server letsencrypt --domain www.southernhikes.co.nz --webroot /var/www/southernhikes.co.nz/system/nginx-root --reloadcmd "nginx -s reload" --accountemail southernhikes@lecontakt.com --keylength 2048
[Sun Mar 10 21:48:24 UTC 2024] Invalid status, www.southernhikes.co.nz:Verify error detail:2606:4700:3037::ac43:970c: Invalid response from http://www.southernhikes.co.nz/.well-known/acme-challenge/xxxxxxxxxxxxxxxxxxxx: 404
[Sun Mar 10 21:48:24 UTC 2024] Please add '--debug' or '--log' to check more details.
[Sun Mar 10 21:48:24 UTC 2024] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh

[Sun Mar 10 21:48:18 UTC 2024] Using CA: https://acme-v02.api.letsencrypt.org/directory
[Sun Mar 10 21:48:18 UTC 2024] Single domain='www.southernhikes.co.nz'
[Sun Mar 10 21:48:18 UTC 2024] Getting domain auth token for each domain
[Sun Mar 10 21:48:21 UTC 2024] Getting webroot for domain='www.southernhikes.co.nz'
[Sun Mar 10 21:48:21 UTC 2024] Verifying: www.southernhikes.co.nz
[Sun Mar 10 21:48:22 UTC 2024] Pending, The CA is processing your order, please just wait. (1/30)

Exit code: 1


Debug Information:
    OS: Ubuntu, v22.04.4 LTS
    Node Version: v18.19.1
    Ghost Version: 5.80.2
    Ghost-CLI Version: 1.25.3
    Environment: production
    Command: 'ghost setup ssl'

Additional log info available in: /home/sysadmin/.ghost/logs/ghost-cli-debug-2024-03-10T21_48_25_689Z.log

After running ghost config ..., you need to run ghost restart for the changes to be picked up. You don’t need to do anything else.

So I reinstalled everything but I landed up with the same issue. It appears to have something to do with CloudFlare, Nginx proxy manager and the way Ghost works with certificates.

Do you have Cloudflare set to strict/full for proxying?

curl --silent https://www.southernhikes.co.nz/ghost/api/admin/site/  | jq .site.url
"http://www.southernhikes.co.nz/"

I’m still getting an HTTP url here. Can you try directly making this request to the Ghost instance, so you’ll either know if Ghost is incorrectly set up, or if there’s a broken cache?

If you run ghost ls, you can get the port that ghost is listening on and replace PORT with that number in the command.

curl --silent http://127.0.0.1:PORT/ghost/api/admin/site/ -H "Host: www.southernhikes.co.nz" -H "X-Forwarded-Proto: https" | sed 's/,/\n/g' | grep url

I have installed the certs and set URL to HTTPS but the image is still not showing when the page loads… it appears to be linked via http and not https.

To make sure that the issue was not else where in the network.

I updated my host file so that the domain pointed directly to my local IP for Ghost and the same thing happens i.e. the site resolves to https without any cert issues but the article images (not video or main blog image) appear as broken links (because of the HTTP reference). If you click on them, they open correctly as the URLS are HTTPS.

I can’t help you if you don’t provide the debug information I’m asking for.

Sorry, missed that request.

It is still saying “url”:“http://www.southernhikes.co.nz/

I also added notes to my previous reply.

sysadmin@webserver-01:/var/www/southernhikes$ sudo curl --silent https://www.southernhikes.co.nz/ghost/api/admin/site/ | jq .site.url “http://www.southernhikes.co.nz/
jq: error: Could not open file http://www.southernhikes.co.nz/: No such file or directory

Can you please run this command:

curl --silent http://127.0.0.1:2368/ghost/api/admin/site/ -H "Host: www.southernhikes.co.nz" -H "X-Forwarded-Proto: https" | jq .site.url
2 Likes

Ok thanks for your help. I think it’s sorted.

The first time I ran it I got HTTP so I reran

host config url https://www.southernhikes.co.nz

And it updated it this time.

I must have been doing something wrong when I tired previously as the update did not happen.

Thanks for your patience and help. I have a good understanding now of how this all hangs together as well as how to troubleshoot this :)

1 Like