Getting Ghost Set Up
4 min read

Getting Ghost Set Up

Years ago I had set up a Ghost blog on my web server.  I never used it much but I had it there and I had a few posts that I liked.  Then when I upgraded Debian to version 10 (Buster) something went wrong and Ghost did no run any more.  Now this is a homelab system and my life has been through some rough going is the last 5 years; so, I had never upgraded Ghost since I installed it in 2017.

Finally about two weeks ago I really wanted to write something (I don't remember what) and tried to revive the site by reinstalling Ghost.  Well, it would not install on Debian using the instructions for Ubuntu.  So I started from scratch.

It works now but, it's been a long road to get here:

I put a container up on my Proxmox server to hold the software and installed a Ubuntu 20.04 image on it.  Then I followed the install directions for Ubuntu (the ones that did not work on Debian) and got Ghost installed with no problems.

But, I only have one IP address coming into my homelab system.  I have port 80 of that system pointed to my main web server which runs Apache.  So I needed to redirect this blog to the new container that was running it.  Easier said than done.

Here's how it went:

First set up the container.  But I have not used containers with Proxmox before.  So why not just set up a new virtual machine (VM) to run it.  Well, VMs take a lot of memory and disk space and I have been meaning to learn about containers on Proxmox, so this seemed an opportunity.  

It really was easy to find the right template and install it.  I did try to use Ubuntu 20.10 and Proxmox refused saying it needed newer host software.  (I hate upgrading Proxmox).  So I figured the long term support version (20.04) was a good choice anyway and downloaded that image using the Proxmox CLI and created a container for it.  

I also tried the Turnkey Linux prebuilt image for Ghost.  But, it's all preconfiured to use an Sqlite database.  That's not what I wanted, I want the data stored in the database I have backup procedures for; which is Mariadb.

The actual setup of the Ubuntu 20.04 container was just as easy as you could want.  But there are always the questions about resource allocation.  So I ran a number of experiments before settling on a configuration.

I ended up using 12 Gb of disk space and only 1 Gb of memory.  This is great when you see that 32 Gb of disk and 4 Gb of memory is about the minimum for a VM.  Now that everything is set up, we are using about 30% of the virtual disk.  Since the blog text is stored on the database server, that should be fine.  I did use a privileged container because I could not find anyway to access SMB shares from an unprivileged container.

I followed the directions here to install Ghost.  I did it several times and there was never any problem except for the times I screwed up by not paying attention.  Every time I got a Nginx web server offering the preinstalled pages.  However, with my old Ghost setup I could access the server directly on port 2368, but I could only get that to work local to container running Ghost.

The biggest problem was getting the external name resolution right.  The problem is the strange way my ISP has my fixed IP address set up.  The fixed IP is actually assigned to an EdgeMAX router at their location.  That router then forwards all ports to my system here which is assigned an address of  Their whole network seems to be built using locally administered addresses with fixed IPs just piggybacked onto the network. This works OK from outside, but prevents my router from detecting that it is the local address and forwarding it back to the node in local network that the port is forwarded to.   Instead everything just gets sent to the EdgeMAX router.  

To get around this, I have to mess with my DNS to make all of the addresses that I put in the external DNS resolve to the local machine I want them to go to.  If my internal network was very complicated this would not be an acceptable solution.  But, most of the names I publish to the Internet I want to resolve to my web server, so it works; but it is a pain because I keep forgetting to set up the name in the internal DNS.

So, I finally got all of that set and... It didn't work.  I got this really odd page with just Ghost menu in gigantic letters.  Very strange.  It appeared that internal links in the website were directed to the internal name not the external name.  It seems to me they all should be made with relative links.

I tried to use redirects to get the site to resolve correctly.  Redirects are described here. Redirects are probably real useful for somethings, but were of no help here.  The symptom stayed the same.

After some messing around I finally found that the ghost configuration is stored in /var/www/<site>/config.production.json.  In this configuration file is the URL for the website.  It must match the external name of the site for the site to work.  So it appears that all of the internal links are built off of this configuration item instead of being relative.

After fixing the web site name, it all seems to work.

Now I just have to learn how the new Ghost works, since it does not seem to bare much relationship to the one I used in 2017.