Let nginx serve static files for your ghost blog

You have probably heard about the blogging platform Ghost. The product is still in its infancy, having reached version 0.4.0 this month. But it's fun to try something so different from the standard Wordpress installation. Just don't expect a feature-complete stable product at this stage.

If you want to try Ghost on your own machine, just download the latest Ghost distribution, and follow the online installation instructions.

After installing Ghost you may want to fine-tune your setup. If you're using nginx as reverse proxy in front of ghost, you should consider making nginx serve all the static files (like images, css, and javascript). Because, this is one thing nginx is really good at, serving static files fast and efficient.

Below is a nginx configuration file, which illustrates how you can setup nginx to:

The ghost specific part of the nginx server config file:

# reverse proxy requests to ghost
location /blog {
  proxy_buffering off;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Scheme $scheme;
  proxy_pass http://localhost:2368;
  proxy_pass_header X-CSRF-Token;
  client_max_body_size 10M;

# serve the static blog assets
rewrite ^/blog(/content/images/.*) $1 break;
location /content/images {
  root /home/ghost/ghost;
  expires 1h;
rewrite ^/blog(/assets.*) $1 break;
location /assets {
  root /home/ghost/ghost/content/themes/casper;
  expires 1h;
rewrite ^/blog/(favicon.ico) /shared/$1 break;
rewrite ^/blog(/shared.*) $1 break;
location /shared {
  root /home/ghost/ghost/core;
  expires 1h;

If you keep an eye on your Ghost log file, you can see if there are even more static files that nginx can serve for you.