Set url on docker compose fail

Hi
I’m using Ghots on docker
image: ghost:5.26-alpine

i did up the container to give it a try

so my first URL inside my yml file
was

url: http://static-ip-on-aws-ligthsail:80

I liked so was trying to improve, I set-up a domain and get the and the ssl certificate and so on. step by step everything worked until I decided to change the url on the yml file, but it does not work… when I change anything in the url and reload the container there is no response, I thought it was the certificate and I was debbuging, but noticed that even inside the aws console with ssh connection when I execute:

wget 127.0.0.1
the local machine should save the index.html file however I got

Connecting to 127.0.0.1 … connected.HTTP request sent, awaiting response… 301 Moved Permanently

I found on the documentation that a I should change the url, with my https://my-domain, so i don’t know what else to do. the request simply does not get anything, if I return to the original yml file, the page responds good again, the wget 127.0.0.1 gets the index.html file inside the machine and the domain and the IP get the blog even using a vpn and also with tor broswer

Can you show us your docker compose file?

The docker container usually just exposes a port. You would still need NGINX set up on the host machine. Have you done that?

Have a look here: Running Ghost on Docker for Your Developer Blog | Draft.dev

my docker file

links:      - my-ghostdb   
 environment:     
 # see https://ghost.org/docs/config/#configuration-options      
database__client: mysql      
database__connection__host:      
database__connection__user:     
database__connection__password:    
database__connection__database:     
# this url value is just an example, and is likely wrong for your environment!        
url: http://3.224.48.252:80
# contrary to the default mentioned in the linked documentation, this image defaults to NODE_ENV=production (so development mode needs to be explicitly specified if desired)      
#NODE_ENV: development    
volumes:      - ./blog:/var/lib/ghost/content

my-ghostdb:    
image: mysql:8.0    
restart: always    
environment:      
MYSQL_ROOT_PASSWORD:     
volumes:      - ./dbghostdata:/var/lib/mysql

thanks for the link, I didn’t use it when when deploy the docker, this is a parallel project for me, sorry for the delay answer.

So, here are my assumptions based on the partial docker-compose file in your latest reply and the deleted reply, that also shows the exposed port (not tested any of that, just giving my thoughts on what I see):

You are exposing the docker container’s port 2368 to port 80 of your host machine. That makes Ghost available on your IP:80.

Now, when you change your URL, let’s say to example.com, and you point example.com to your server’s IP address, port 80 should be successfully resolved, given that it’s the standard HTTP port. You should, therefore, see the Ghost site when accessing example.com in your browser.

In your original post you mentioned that wget 127.0.0.1 is returning a 301 HTTP code. In my opinion, that is also correct, given that Ghost is not listening to 127.0.0.1 but example.com now. Ghost is trying to redirect you to example.com, as far as I can see, since that is the value you set as url.

Now, running Ghost in docker is super handy – but it complicates connecting it to a domain. In my opinion, the easiest way for you to expose Ghost do the internet and use a domain rather than the IP address would be a reverse proxy on the host machine. This could then also take care of SSL certificate etc.