OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Set hosts config when present in config
Oliver Günther60cff7aed15a
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rbindex e43be130be4..09e3da12742 100644--- a/config/constants/settings/definition.rb+++ b/config/constants/settings/definition.rb@@ -532,6 +532,10 @@ module Settingsproduction: nil},},+ additional_host_names: {+ description: "Additional allowed host names for the application.",+ default: []+ },hours_per_day: {description: "This will define what is considered a “day” when displaying duration in a more natural way " \"(for example, if a day is 8 hours, 32 hours would be 4 days).",diff --git a/config/environments/production.rb b/config/environments/production.rbindex 7a7ad94774d..049128f4656 100644--- a/config/environments/production.rb+++ b/config/environments/production.rb@@ -179,11 +179,14 @@ Rails.application.configure do}end- # Enable DNS rebinding protection and other `Host` header attacks.- # config.hosts = [- # "example.com", # Allow requests from example.com- # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`- # ]- # Skip DNS rebinding protection for the default health check endpoint.- # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }+ if OpenProject::Configuration.host_name.present?+ # Enable DNS rebinding protection and other `Host` header attacks.+ config.hosts = [OpenProject::Configuration.host_name] + OpenProject::Configuration.additional_host_names+ # Skip DNS rebinding protection for the default health check endpoint.+ config.host_authorization = {+ exclude: ->(request) do+ request.path.start_with?("#{OpenProject::Configuration["rails_relative_url_root"]}/health_check")+ end+ }+ endenddiff --git a/lib/tasks/packager.rake b/lib/tasks/packager.rakeindex b00116f14f1..f0a6d541ec2 100644--- a/lib/tasks/packager.rake+++ b/lib/tasks/packager.rake@@ -63,7 +63,11 @@ namespace :packager do# Persist configurationSetting.sys_api_enabled = 1Setting.sys_api_key = ENV.fetch("SYS_API_KEY", nil)- Setting.host_name = ENV.fetch("SERVER_HOSTNAME", Setting.host_name) if Setting.host_name_writable?+ env_host_name = ENV["SERVER_HOSTNAME"]+ # Write the ENV provided host name as a setting so it is no longer writable+ if env_host_name.present?+ shell_setup(["config:set", "OPENPROJECT_HOST__NAME=#{host_name}"])+ end# SERVER_PROTOCOL is set by the packager apache2 addon# other SERVER_PROTOCOL_xxx variables can be manually set by user