Skip to content

Commit 21e55ca

Browse files
committed
added RAILS_RELATIVE_URL_ROOT support
1 parent e9394c4 commit 21e55ca

File tree

7 files changed

+16
-7
lines changed

7 files changed

+16
-7
lines changed

app/mailers/notify.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Notify < ActionMailer::Base
66
default_url_options[:host] = Gitlab.config.gitlab.host
77
default_url_options[:protocol] = Gitlab.config.gitlab.protocol
88
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
910

1011
default from: Gitlab.config.gitlab.email_from
1112

config.ru

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# This file is used by Rack-based servers to start the application.
22

33
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

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ gitlab:
1818
host: localhost
1919
port: 80
2020
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
2124

2225
## Email settings
2326
# Email address used in the "From" field in mails sent by GitLab

config/initializers/1_settings.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def build_gitlab_url
2525
[ gitlab.protocol,
2626
"://",
2727
gitlab.host,
28-
custom_port
28+
custom_port,
29+
gitlab.relative_url_root
2930
].join('')
3031
end
3132
end
@@ -45,6 +46,7 @@ def build_gitlab_url
4546
Settings.gitlab['host'] ||= 'localhost'
4647
Settings.gitlab['https'] ||= false
4748
Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80
49+
Settings.gitlab['relative_url_root'] ||= ''
4850
Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
4951
Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
5052
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)

config/routes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
project_root: Gitlab.config.gitolite.repos_path,
1919
upload_pack: Gitlab.config.gitolite.upload_pack,
2020
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) }
2222

2323
#
2424
# Help

config/unicorn.rb.example

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
app_dir = "/home/gitlab/gitlab/"
26
worker_processes 2
37
working_directory app_dir

lib/gitlab/backend/grack_auth.rb

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ def valid?
1717
# Pass Gitolite update hook
1818
ENV['GL_BYPASS_UPDATE_HOOK'] = "true"
1919

20-
# Need this patch due to the rails mount
21-
@env['PATH_INFO'] = @request.path
22-
@env['SCRIPT_NAME'] = ""
23-
2420
# Find project by PATH_INFO from env
2521
if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a
2622
self.project = Project.find_with_namespace(m.last)

0 commit comments

Comments
 (0)