diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-16 12:53:54 +0100 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-01-31 22:50:40 +0000 |
commit | fa68e403e0d5539b19ceb5396394d634babdc2b9 (patch) | |
tree | f4e423e06bd4204d18f87783f024bd4e568c4964 /config | |
parent | ac09f857cd9edd4a18280f617b48fe436109ceaa (diff) | |
download | gitlab-ce-fa68e403e0d5539b19ceb5396394d634babdc2b9.tar.gz |
Support https and custom port for pages
Diffstat (limited to 'config')
-rw-r--r-- | config/gitlab.yml.example | 2 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 28 |
2 files changed, 21 insertions, 9 deletions
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index d41280624ae..fa764844cb9 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -163,6 +163,8 @@ production: &base # http://group.example.com/project # or project path can be a group page: group.example.com domain: example.com + port: 80 # Set to 443 if you serve the pages with HTTPS + https: false # Set to true if you serve the pages with HTTPS ## Mattermost ## For enabling Add to Mattermost button diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 0c06b73ba36..3932745e20c 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -5,8 +5,8 @@ class Settings < Settingslogic namespace Rails.env class << self - def gitlab_on_standard_port? - gitlab.port.to_i == (gitlab.https ? 443 : 80) + def on_standard_port?(config) + config.port.to_i == (config.https ? 443 : 80) end def host_without_www(url) @@ -14,7 +14,7 @@ class Settings < Settingslogic end def build_gitlab_ci_url - if gitlab_on_standard_port? + if on_standard_port?(gitlab) custom_port = nil else custom_port = ":#{gitlab.port}" @@ -27,6 +27,10 @@ class Settings < Settingslogic ].join('') end + def build_pages_url + base_url(pages).join('') + end + def build_gitlab_shell_ssh_path_prefix user_host = "#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}" @@ -42,11 +46,11 @@ class Settings < Settingslogic end def build_base_gitlab_url - base_gitlab_url.join('') + base_url(gitlab).join('') end def build_gitlab_url - (base_gitlab_url + [gitlab.relative_url_root]).join('') + (base_url(gitlab) + [gitlab.relative_url_root]).join('') end # check that values in `current` (string or integer) is a contant in `modul`. @@ -74,11 +78,11 @@ class Settings < Settingslogic private - def base_gitlab_url - custom_port = gitlab_on_standard_port? ? nil : ":#{gitlab.port}" - [ gitlab.protocol, + def base_url(config) + custom_port = on_standard_port?(config) ? nil : ":#{config.port}" + [ config.protocol, "://", - gitlab.host, + config.host, custom_port ] end @@ -254,11 +258,17 @@ Settings.registry['issuer'] ||= nil Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') Settings.registry['path'] = File.expand_path(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'), Rails.root) +# # Pages +# Settings['pages'] ||= Settingslogic.new({}) Settings.pages['enabled'] = false if Settings.pages['enabled'].nil? Settings.pages['path'] = File.expand_path('shared/pages/', Rails.root) Settings.pages['domain'] ||= "example.com" +Settings.pages['https'] = false if Settings.pages['https'].nil? +Settings.pages['port'] ||= Settings.pages.https ? 443 : 80 +Settings.pages['protocol'] ||= Settings.pages.https ? "https" : "http" +Settings.pages['url'] ||= Settings.send(:build_pages_url) # # Git LFS |