Apache + Passenger で動かしていた Redmine を Nginx + Unicorn に移行したのでそのメモ。
設定した環境
-
フロントの Nginx は https である。
-
Redmine は /var/redmine にインストールされている。
-
URL はドメイン/redmine で受ける.
-
VPS 環境でUbuntu でスペックは低め。
Unicorn のインストール
Redmine ディレクトリのルートに Gemfile.local を作る。
# Gemfile.local gem “unicorn”
bundler で Unicorn をインストール
$ bundle install
Unicorn の設定スクリプト
Redmine ディレクトリの config に unicorn.rb を下記のとおり作成する。
|
|
- 初回アクセス時にタイムアウトしないように 60 秒に増やす。
- 数人しかアクセスしないのでワーカーは 1 つにする。
Nginx の設定
upstream redmine {
server unix:/var/redmine/tmp/sockets/unicorn.sock;
}
…
location /redmine {
root /var/redmine/public;
if ( -f $request_filename ) { break; }
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://redmine;
}
…
Unicorn 起動
Unicorn で Redmine を起動
$ bundle exec unicorn_rails -c config/unicorn.rb -D -E production –path /redmine