Commit 151ada7645f112d5cae365a812a1076835100f8a
Exists in
master
and in
4 other branches
Merge pull request #2162 from frohoff/config-improvements
support for running in non-root directory/path (RAILS_RELATIVE_URL_ROOT)
Showing
7 changed files
with
16 additions
and
7 deletions
Show diff stats
app/mailers/notify.rb
| @@ -6,6 +6,7 @@ class Notify < ActionMailer::Base | @@ -6,6 +6,7 @@ class Notify < ActionMailer::Base | ||
| 6 | default_url_options[:host] = Gitlab.config.gitlab.host | 6 | default_url_options[:host] = Gitlab.config.gitlab.host |
| 7 | default_url_options[:protocol] = Gitlab.config.gitlab.protocol | 7 | default_url_options[:protocol] = Gitlab.config.gitlab.protocol |
| 8 | default_url_options[:port] = Gitlab.config.gitlab.port if Gitlab.config.gitlab_on_non_standard_port? | 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 | default from: Gitlab.config.gitlab.email_from | 11 | default from: Gitlab.config.gitlab.email_from |
| 11 | 12 |
config.ru
| 1 | # This file is used by Rack-based servers to start the application. | 1 | # This file is used by Rack-based servers to start the application. |
| 2 | 2 | ||
| 3 | require ::File.expand_path('../config/environment', __FILE__) | 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,6 +18,9 @@ gitlab: | ||
| 18 | host: localhost | 18 | host: localhost |
| 19 | port: 80 | 19 | port: 80 |
| 20 | https: false | 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 | ## Email settings | 25 | ## Email settings |
| 23 | # Email address used in the "From" field in mails sent by GitLab | 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,7 +25,8 @@ class Settings < Settingslogic | ||
| 25 | [ gitlab.protocol, | 25 | [ gitlab.protocol, |
| 26 | "://", | 26 | "://", |
| 27 | gitlab.host, | 27 | gitlab.host, |
| 28 | - custom_port | 28 | + custom_port, |
| 29 | + gitlab.relative_url_root | ||
| 29 | ].join('') | 30 | ].join('') |
| 30 | end | 31 | end |
| 31 | end | 32 | end |
| @@ -45,6 +46,7 @@ Settings.gitlab['default_projects_limit'] ||= 10 | @@ -45,6 +46,7 @@ Settings.gitlab['default_projects_limit'] ||= 10 | ||
| 45 | Settings.gitlab['host'] ||= 'localhost' | 46 | Settings.gitlab['host'] ||= 'localhost' |
| 46 | Settings.gitlab['https'] ||= false | 47 | Settings.gitlab['https'] ||= false |
| 47 | Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 | 48 | Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 |
| 49 | +Settings.gitlab['relative_url_root'] ||= '' | ||
| 48 | Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http" | 50 | Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http" |
| 49 | Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}" | 51 | Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}" |
| 50 | Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) | 52 | Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) |
config/routes.rb
| @@ -18,7 +18,7 @@ Gitlab::Application.routes.draw do | @@ -18,7 +18,7 @@ Gitlab::Application.routes.draw do | ||
| 18 | project_root: Gitlab.config.gitolite.repos_path, | 18 | project_root: Gitlab.config.gitolite.repos_path, |
| 19 | upload_pack: Gitlab.config.gitolite.upload_pack, | 19 | upload_pack: Gitlab.config.gitolite.upload_pack, |
| 20 | receive_pack: Gitlab.config.gitolite.receive_pack | 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 | # Help | 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 | app_dir = "/home/gitlab/gitlab/" | 5 | app_dir = "/home/gitlab/gitlab/" |
| 2 | worker_processes 2 | 6 | worker_processes 2 |
| 3 | working_directory app_dir | 7 | working_directory app_dir |
lib/gitlab/backend/grack_auth.rb
| @@ -17,10 +17,6 @@ module Grack | @@ -17,10 +17,6 @@ module Grack | ||
| 17 | # Pass Gitolite update hook | 17 | # Pass Gitolite update hook |
| 18 | ENV['GL_BYPASS_UPDATE_HOOK'] = "true" | 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 | # Find project by PATH_INFO from env | 20 | # Find project by PATH_INFO from env |
| 25 | if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a | 21 | if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a |
| 26 | self.project = Project.find_with_namespace(m.last) | 22 | self.project = Project.find_with_namespace(m.last) |