7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

XAMPP上のapacheでリバースプロキシを使ってWebrick上で動作しているredmineにアクセス

Last updated at Posted at 2014-06-16

既にXAMPPのインストールと、redmineのインストールを済ませているものとして話を進めます。

redmine の環境

Environment:
Redmine version 2.5.1.stable
Ruby version 2.0.0-p353 (2013-11-22) [x64-mingw32]
Rails version 3.2.17
Environment production
Database adapter SQLite

リバースプロキシの設定

apache が C:\xampp\apache に インストールされているとして httpd.conf を編集

C:\xampp\apache\httpd.conf
# こいつをコメントアウト
LoadModule proxy_http_module modules/mod_proxy_http.so 

続いて extra\httpd-proxy.conf を編集

C:\xampp\apache\extra\httpd-proxy.conf
<IfModule proxy_module>
<IfModule proxy_http_module>
# 以下の2行を追加. IP部分は適宜変更
ProxyPass /redmine http://127.0.0.1:3000/redmine
ProxyPassReverse /redmine http://127.0.0.1:3000/redmine

上記の編集を終えたら、apache再起動.

Redmineの設定

redmineフォルダ直下のconfig.ruを編集する

config.ru
require ::File.expand_path('../config/environment',  __FILE__)
if ENV['RAILS_RELATIVE_URL_ROOT']
  map ENV['RAILS_RELATIVE_URL_ROOT'] do
    run RedmineApp::Application
  end
else
  run RedmineApp::Application
end

sinatra だとこれだけでOKだが、Webrick の場合、以下のファイルを編集する

C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\rack-1.4.5\lib\rack\handler\webrick.rb
def service(req, res)
  env = req.meta_vars
  #以下の行を追加。@app.call(env)より前であればここじゃなくてもいい。
  env["HTTP_HOST"] = "#{env["SERVER_NAME"]}:#{env["SERVER_PORT"]}"

コマンドプロンプトを起動し、以下のコマンドを入力

> set RAILS_RELATIVE_URL_ROOT=/redmine
> ruby script/rails server webrick -e production

完了

上記設定を完了した後、http://127.0.0.1/redmine にアクセスすると http://127.0.0.1:3000/redmine の情報が表示されるはず。

ポイントはWebrickでsub-uriでアクセスする際はrackのrubyスクリプトをいじる必要があるということかなぁ。これが正解だとは思っていないので、要調査。

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?