Old Stuff - 'ThinServer' blogging - Part 2

Part two from the ThinServer that ran Ghost and shared content with the world from a corner of my lounge 4 years ago.


This is the second of three posts covering how to create a simple low cost webserver for blogging. In the first part we  covered the basic installation of the server, but as things stand it has a few issues. Firstly it's listening on a non-standard port and that needs to be resolved. Secondly it is running in development mode, so we need to get the thinserver ready for production.

But first we need to talk about your internet. If you are going to put this box on the internet then there are a few ways of doing it. I am going to make the assumption that you don't have a domain name of your own and you just have a regular broadband connection which doesn't have a fixed IP address. If this is the case then checkout my post on 'DuckDNS' which is an excellent (and free) dynamic DNS service. This article assumes that you have used DuckDNS and have a DNS name. I'm going to use example.duckdns.org in the rest of the posts - you just need to substitute whatever you have chosen.

1) Edit config.js

There is a fantastic guide by the really nice people over at Ghost, so rather than try to repeat that here, what I have done is shared up a ZIP file of my sample config files that way you can pull them down, edit them and reuse them. Just remember to replace...

  • example.duckdns.org with your own domain name from duckdns.
  • 192.168.20.30 for the IP address you gave the thinserver. If you ever change this then you'll need to update this file and your port forwarding details on your router.
  • example@gmail.com with your own Gmail email address. What? You don't have one? Well I'd suggest you get one as it's not a good idea to put your own personal email address in the wild. Unless of course you like spam. Or spam, spam, egg and spam.

Now you can use notepad for editing config.js, but I'd recommend upgrading to the portable version of notepad++ available here. As previously discussed you'll need to expand this on a 'proper' PC or laptop before copying the expanded files over and making a shortcut.

If youwant to dig a little deeper on config.js then you could do a good deal worse than looking at this post over at All About Ghost

2) Use NGINX to proxy Ghost to port 80

Now you don't actually need to do this if you have a swanky router that can twist ports when it port forwards. I am going to assume that you don't and that you need another method of twisting Ghosts default port (2368) to the regular HTTP port (80).

Head on over to NGINX for windows and download the latest zip file. (The latest version as I am writing this is 1.7.10). You don't even need to install NGINX, just expand it to C:\nginx-1.7.10 and you and almost done.

You need to make a small edit to the nginx.conf file. Open it with either notepad or ideally notepad++ and change the server_name line...

server {
    listen       80;
    server_name  example.duckdns.org 192.168.20.10;

As you did before in the config.js file, swap in yourdomain name and the correct local IP address for your thinserver.

If you also look in my zip file of example config you'll find a couple of small batch files cunningly named start_nginx.bat and stop_nginx.bat. Just copy these out to the desktop of your thinserver and you'll be able to stop and start the NGINX proxy with a few clicks. If the version has updated from 1.7.10 then your directory name will have changed and you'll need to make a small edit in both batch files to reflect this. Once again notepad or notepad++ will do the job here.

OK, time to give it a try. Double click on the start_nginx.bat batch file or it's shortcut. NGINX will start in a seperate command prompt window to Ghost. We are not ready to test yet as we need to get Ghost running in production mode. We'll tackle that next and also things to start automatically when the thinserver starts.

3) Setting up for automatic start

There are three things we need to do.

First lets get NGINX to start automatically. Thats simple - just make a shortcut to the start_nginx.bat file and pop it into the startup folder in the start menu. Yes you can run NGINX as a service, which is technically the better solution but this is a thinserver and simple=better when you have limited system resources.

Second, we need to get Ghost running into the production environment. The simple (but admittedly cludgy) what of doing this is to modify the nodevars.bat file. If you've stuck to the default install then this is located in the C:\Program Files\nodejs\ folder. Locate the nodevars.bat,open it with notepad or notepad++ and append the following lines at the end of the file

cd C:\ghost-0.5.10
c:
npm start --production

Now copy the Node.js command prompt shortcut that will have been added to the start menu and paste it into the startup folder on the menu.

Thirdly, the thinserver must be set to automatically log itself in when it is powered up. Open up Control Panel on the thinserver and double click the HP Login Manager. Enter the Administrator account credentials and leave the domain name blank. Tick both boxes and click OK.

OK, time to give it a test. Restart the thinserver and let things happen. You'll see a couple of command prompts running, indicating the both Ghost and NGINX are running.

Open up a web browser, type 127.0.0.1 into the URL bar and hit enter - if all has gone well then you should be able to see your Ghost blog. If you can't see the blog then you need to check your typing and that both NGINX and Ghost are running.

Now if you have also got port forwarding and a duckdns setup in place, you should now be able to type your domain name - e.g. example.duckdns.org into the browser and you should see the exact same Ghost blog.If you didn't then you need to check your port forwarding is pointing to the correct local IP.

That's the basic setup in place and the third part of this series will deal with setting things up inside of Ghost itself.

Creative Commons License


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.