Running Ghost behind Apache Reverse Proxy

After migrating to Ghost a couple of days ago, I wanted to hide the application behind my Apache HTTP Server. Because I’m running my blog on a subdomain I already had a VirtualHost configured, so the question was how to set up mod_proxy to forward all requests to Ghost.

Here’s my apache configuration for the virtual host on which my blog is hosted on my server:

<Virtualhost *:80>
  ServerName blog.myserver.tld
  ServerAlias www.myserver.tld blog.myserver.tld
  ServerAdmin webmaster@localhost
  RewriteEngine On
  RewriteOptions Inherit
  # rewrite jekyll URLs to Ghost URLs
  RewriteRule ^/\d{4}-\d{2}-\d{2}-(.+?)/?$ $1 [R]
  RewriteRule ^/\d{4}/\d{2}/\d{2}/(.+?)/?$ $1 [R]
  # previous feed address to ghost feed
  RewriteRule ^/atom\.xml$ /rss [R]
  <ifmodule mod_proxy.c>
    ProxyVia On
    ProxyRequests Off
    ProxyPass /
    ProxyPassReverse /
    ProxyPreserveHost on
    <proxy *>
      AllowOverride All
      Order allow,deny
      allow from all

You can also see my RewriteRules here that help me keep old URLs from my Jekyll blog and not loose any search results due to broken URLs. That was quite important to me, because I think you shouldn’t break URLs when migrating your underlying software. Unfortunately, Ghost does not yet provide a mechanism to customize the URLs, so I had to go with this redirects as suggested by W3C.

Additionally, with real redirects I can instruct Disqus to crawl my website again and auto-fix all comments, which are tied to URLs in their system. No more URL mapping spreadsheets to edit! :-)

Weitere Artikel

Crossfit Open WOD 18.4

Crossfit Open WOD 18.3

Crossfit Open WOD 18.2

Crossfit Open WOD 18.1

Match only your own email in Evolution filters

Gronkh ist jetzt ein Rundfunksender...

Crossfit Regionals 2018 in Berlin

Crossfit Open 2018

Qutebrowser userscript for TT-RSS

Aufbau eines Hackintosh