Back Online: Issues with Running Ghost Using nginx

After nearly two years of not updating this blog, I finally decided that I should do a better job of sharing some of the projects I have. I will turn this into a blog, and turn my website into more of a portfolio. I actually started this endeavor about a month ago, but after neglecting my applications, they had stopped, and I had no idea how to get them working again. I vaguely remember Amazon sending some emails about restarting or moving my ec2 instance, which probably caused some of the issues. I gave it another attempt to work, and now it's back up. This post will detail my troubleshooting process and what finally worked.

When I attempted to view my website, it was no longer working. I didn't think too much of it, as it had been a while, and surely something had changed. Sure enough, one of the first issues I found was the the name of the server had changed to a new address. I attempted to change the server name, but still could not access the website. I then read some more about installing nginx to run the app, then still failed. I spent a bit of time trying to configure and set up nginx, but could not get the website online. I gave up at the time, then came back to it.

After returning, I figured out that the config files for nginx were a complete mess. After reinstalling the default nginx.conf file, I then created a ghost.conf file within the drive conf.d. The ghost.conf file was the same as on the blog as below:

server {  
    listen 80;
    server_name explorenothing.com;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;

        proxy_pass http://127.0.0.1:2368;
    }
}

Ah, now nginx was at least attempting to route, but I kept ending up with 502 Bad Gateway errors! What could possibly be causing these?!?!

Eventually, I figured out that the error was discussing a refused connection. Some more internet sleuthing finally revealed the following change under the production environment variables of the config.js file:
from:

server: }  
    host: 'address of the ec2instance.amazonaws.com',
    port: '2368'
}

to the correct

server: {  
    host: '127.0.0.1',
    port: '2368'
}

Aha! Now it works, and my blog is running again. I am using the forever command to make it continue to run after exiting from the session.

Hopefully this will be the beginning of a new streak of blogging; however, December will be very busy, so maybe I'll actually get things going again in January.