Geminaboxをhttpsなnginxプロキシ+apacheで使う

備忘録的にクイックメモ

こんな構成

 user -(https)-> nginx -(http)-> apache(passenger) 

nginxのconf

    location /geminabox {
        proxy_set_header Host                   $host;
        proxy_set_header X-Forwarded-Host       $host;
        proxy_set_header X-Forwarded-Server     $host;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto      https; # これがないとgeminaboxがhttpとしてハンドリングしちゃう。
        proxy_pass http://host/geminabox;
    }

apachのconf

<VirtualHost *:80>
  DocumentRoot /u/apps
  <Directory /u/apps>
    Allow from all
  </Directory>

  LogLevel info
  CustomLog ${APACHE_LOG_DIR}/apps_access.log combined
  ErrorLog ${APACHE_LOG_DIR}/apps_error.log

  RackBaseURI /geminabox
  <Directory /u/apps/geminabox>
    Options -MultiViews
  </Directory>
</VirtualHost>

Geminaboxはgemじゃなくてリポジトリのそのまま使った。

$ git clone https://github.com/cwninja/geminabox

RakBaseURIに合わせるためにconfig.ruをちょこっと編集。SCRIPT_NAMEにRackBaseURIに指定したものを入れる。

diff --git a/config.ru b/config.ru
index 397ff92..6700f83 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,6 @@
 $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
 require "geminabox"
 
+ENV['SCRIPT_NAME'] = 'geminabox'
+Geminabox.data = '/var/geminabox-data'
 run Geminabox