Tips Ghost Self hosted

Adding ads.txt self-hosted ghost with nginx

This is a bit tricky, I tried downloading the template and adding an ads.txt then reuploading it... Doesn't work... I tried just creating an ads.txt on the template folder... Doesn't work. Not to forget after adding/updating run the command ghost restart... Still doesn't work. (maybe cached so maybe you need to try incognito)

Well what works for me is adding this piece of line from the nginx config of the site that is

location ~ ^/ads.txt {
  root /var/www/static/sitename;
}

so what I did was make a separate folder just for static then add the ads.txt there, Now it works.

Update 16/03/2024: I think because there's an update on Ghost and I tried to add ads.txt to the root directory of the template it now works.

Changing HTTP to HTTPS

This is surprisingly easy, although had trouble upgrading self-Ghost CLI (turns out you didn't have to).

ghost setup nginx ssl
ghost restart

The command above created a new nginx conf, it made a bit of a mess, it just loop redirects, so it was a bit of hacking... just copied the generated to the real one for the SSL, and the one without SSL just redirected to SSL.

service nginx restart

After Ghost restart, It goes to 502 bad gateway

Just happened to restart then it went 502, after a bit of research it has to do something with proxy_pass nginx. It shows this error on the Nginx log.

connect() failed (111: Connection refused) while connecting to upstream

to fix this

netstat -plant

find a port that has a node in it... In my case the port is different, so I changed it to the active port listener then it works