Http/https problems in Docker, Ghost, NGINX Reverse Proxy and cloudflare

Hello,

I have been trying to setup ghost using docker on my a Raspberry pi in my home network behind an NGINX Proxy Manger docker instance and cloudflare dns.

https://domain.com → cloudflare → http://192.169.0.245:80(ngnix reverse proxy) → http://192.169.0.245:2368(ghost)

I was successful in getting the config up and running, but when I am using it, I am unable to get previews and the images I upload are not loading properly due to the following error in console

Mixed Content: The page at ‘https://domain.com/gear/’ was loaded over HTTPS, but requested an insecure image ‘http://domain.com/content/images/size/w1000/2024/11/q10-2.png’. This request has been blocked; the content must be served over HTTPS.

I understand the issue is being caused by my url in ghost docker compose which is http://domain.com rather than https://domain.com. but If I change it to https the ghost container is not coming up and the logs show 301 status code in a loop

[2024-11-10 04:28:24] INFO “GET /” 301 44ms
[2024-11-10 04:28:25] INFO “GET /” 301 6ms
[2024-11-10 04:28:25] INFO “GET /” 301 6ms
[2024-11-10 04:28:25] INFO “GET /” 301 2ms

I read through lot of posts and help articles and the proposed fix is to enable the following in my nginx proxy as mentioned here

proxy_set_header X-Forwarded-Proto https

I am new nginx reverse proxy and am unable to figure out how to add the proxy_set_header in my nginx config.

I tried adding it to the nginx.conf file and in the advanced section in the nginx proxy UI but those things did not fix the issue.

I have been debugging this issue for more than 2 days and the forum has multiple posts (1 & 2) but none of them have any resolution.

I would be very grateful if you can point me in the right direction.

I figured out the issue.

I had to route my home traffic through 443 port rather than 80 and configure let’s encrypt certificate with cloudflare dns challenge to the url in Ngnix proxy manager proxy host.

did not have to modify any conf file related to nginx