Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/mailers/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Notify < ActionMailer::Base
default_url_options[:host] = Gitlab.config.gitlab.host
default_url_options[:protocol] = Gitlab.config.gitlab.protocol
default_url_options[:port] = Gitlab.config.gitlab.port if Gitlab.config.gitlab_on_non_standard_port?
default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root

default from: Gitlab.config.gitlab.email_from

Expand Down
5 changes: 4 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Gitlab::Application

map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
run Gitlab::Application
end
3 changes: 3 additions & 0 deletions config/gitlab.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ gitlab:
host: localhost
port: 80
https: false
# uncomment and customize to run in non-root path
# note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/unicorn.rb may need to be changed
# relative_url_root: /gitlab

## Email settings
# Email address used in the "From" field in mails sent by GitLab
Expand Down
4 changes: 3 additions & 1 deletion config/initializers/1_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def build_gitlab_url
[ gitlab.protocol,
"://",
gitlab.host,
custom_port
custom_port,
gitlab.relative_url_root
].join('')
end
end
Expand All @@ -45,6 +46,7 @@ def build_gitlab_url
Settings.gitlab['host'] ||= 'localhost'
Settings.gitlab['https'] ||= false
Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80
Settings.gitlab['relative_url_root'] ||= ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found using

Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''

is more flexible. one can set it an env file, directly in the Procfile, in config/unicorn.rb, in /etc/init.d/gitlab and not need to bother with the setting in config/gitlab.yml. DRY and such.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikew I've been wondering if it could be more DRY. Do email notifications get URLs built with the proper path prefix in that configuration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, haven't gotten an email from my gitlab install in a while. not even sure if it is configured properly. what's the quickest way to get gitlab to send an email? though an actual spec would be best, of course.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, "forgot password"
mail couldn't send, but reading it via postcat -q I can see the proper RAILS_RELATIVE_URL_ROOT is there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I'll give that a test when I get a chance. You going to submit a pull request or should I?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the process now. just a minute.

Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
project_root: Gitlab.config.gitolite.repos_path,
upload_pack: Gitlab.config.gitolite.upload_pack,
receive_pack: Gitlab.config.gitolite.receive_pack
}), at: '/:path', constraints: { path: /[-\/\w\.-]+\.git/ }
}), at: '/', constraints: lambda { |request| /[-\/\w\.-]+\.git/.match(request.path_info) }

#
# Help
Expand Down
4 changes: 4 additions & 0 deletions config/unicorn.rb.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# uncomment and customize to run in non-root path
# note that config/gitlab.yml web path should also be changed
# ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"

app_dir = "/home/gitlab/gitlab/"
worker_processes 2
working_directory app_dir
Expand Down
4 changes: 0 additions & 4 deletions lib/gitlab/backend/grack_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ def valid?
# Pass Gitolite update hook
ENV['GL_BYPASS_UPDATE_HOOK'] = "true"

# Need this patch due to the rails mount
@env['PATH_INFO'] = @request.path
@env['SCRIPT_NAME'] = ""

# Find project by PATH_INFO from env
if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a
self.project = Project.find_with_namespace(m.last)
Expand Down