Commit 21e55ca318bb829399c85b10e678b596d6fd414e

Authored by Chris Frohoff
1 parent e9394c48

added RAILS_RELATIVE_URL_ROOT support

app/mailers/notify.rb
... ... @@ -6,6 +6,7 @@ class Notify < ActionMailer::Base
6 6 default_url_options[:host] = Gitlab.config.gitlab.host
7 7 default_url_options[:protocol] = Gitlab.config.gitlab.protocol
8 8 default_url_options[:port] = Gitlab.config.gitlab.port if Gitlab.config.gitlab_on_non_standard_port?
  9 + default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root
9 10  
10 11 default from: Gitlab.config.gitlab.email_from
11 12  
... ...
config.ru
1 1 # This file is used by Rack-based servers to start the application.
2 2  
3 3 require ::File.expand_path('../config/environment', __FILE__)
4   -run Gitlab::Application
  4 +
  5 +map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
  6 + run Gitlab::Application
  7 +end
... ...
config/gitlab.yml.example
... ... @@ -18,6 +18,9 @@ gitlab:
18 18 host: localhost
19 19 port: 80
20 20 https: false
  21 + # uncomment and customize to run in non-root path
  22 + # note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed
  23 + # relative_url_root: /gitlab
21 24  
22 25 ## Email settings
23 26 # Email address used in the "From" field in mails sent by GitLab
... ...
config/initializers/1_settings.rb
... ... @@ -25,7 +25,8 @@ class Settings < Settingslogic
25 25 [ gitlab.protocol,
26 26 "://",
27 27 gitlab.host,
28   - custom_port
  28 + custom_port,
  29 + gitlab.relative_url_root
29 30 ].join('')
30 31 end
31 32 end
... ... @@ -45,6 +46,7 @@ Settings.gitlab['default_projects_limit'] ||= 10
45 46 Settings.gitlab['host'] ||= 'localhost'
46 47 Settings.gitlab['https'] ||= false
47 48 Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80
  49 +Settings.gitlab['relative_url_root'] ||= ''
48 50 Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
49 51 Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
50 52 Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
... ...
config/routes.rb
... ... @@ -18,7 +18,7 @@ Gitlab::Application.routes.draw do
18 18 project_root: Gitlab.config.gitolite.repos_path,
19 19 upload_pack: Gitlab.config.gitolite.upload_pack,
20 20 receive_pack: Gitlab.config.gitolite.receive_pack
21   - }), at: '/:path', constraints: { path: /[-\/\w\.-]+\.git/ }
  21 + }), at: '/', constraints: lambda { |request| /[-\/\w\.-]+\.git/.match(request.path_info) }
22 22  
23 23 #
24 24 # Help
... ...
config/unicorn.rb.example
  1 +# uncomment and customize to run in non-root path
  2 +# note that config/gitlab.yml web path should also be changed
  3 +# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
  4 +
1 5 app_dir = "/home/gitlab/gitlab/"
2 6 worker_processes 2
3 7 working_directory app_dir
... ...
lib/gitlab/backend/grack_auth.rb
... ... @@ -17,10 +17,6 @@ module Grack
17 17 # Pass Gitolite update hook
18 18 ENV['GL_BYPASS_UPDATE_HOOK'] = "true"
19 19  
20   - # Need this patch due to the rails mount
21   - @env['PATH_INFO'] = @request.path
22   - @env['SCRIPT_NAME'] = ""
23   -
24 20 # Find project by PATH_INFO from env
25 21 if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a
26 22 self.project = Project.find_with_namespace(m.last)
... ...