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 / http://www.kopis.de:2368/
    ProxyPassReverse / http://www.kopis.de:2368/
    ProxyPreserveHost on
    <proxy *>
      AllowOverride All
      Order allow,deny
      allow from all
    </proxy>
  </ifmodule>
</Virtualhost>

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

Neue Tastatur: Pok3r Vortex RGB

New minecraft survival mod for 1.11.2

Änderungen beim Flug mit Quadkoptern

Ein paar Fotos

Nach den Crossfit Open

Crossfit Open WOD 17.5

Crossfit Open WOD 17.4

Crossfit Open WOD 17.3

Crossfit Open Workout 17.2

Crossfit Open Workout 17.1