Skip to content

Commit

Permalink
Allow multiple hostname
Browse files Browse the repository at this point in the history
Signed-off-by: pratixha <pratiksha.prajapati@msystechnologies.com>
  • Loading branch information
pratixha committed May 13, 2022
1 parent 9332e97 commit 3f5f49b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs-chef-io/content/supermarket/config_rb_supermarket.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ This configuration file has the following general settings:
`default['supermarket']['fqdn']`

: The fully qualified domain name for the Supermarket server. Defaults to using the current FQDN for the machine.
: For allowing multiple hostname in `default['supermarket']['fqdn']`, specify `node['hostname']` separated by coma.
eg. node['https://hostname1.example1.com', https://hostname2.example2.com]

`default['supermarket']['disable_host_header_attack']`

Expand Down
2 changes: 2 additions & 0 deletions omnibus/cookbooks/omnibus-supermarket/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

# The fully qualified domain name. Will use the node's fqdn if nothing is
# specified.
# node['hostname'] can allow multiple hostname separated by coma.
# eg. node['hostname.example1.com', hostname.example2.com]
default['supermarket']['fqdn'] = (node['fqdn'] || node['hostname']).downcase

# The URL for the Chef server. Used with the "Chef OAuth2 Settings" and
Expand Down
5 changes: 4 additions & 1 deletion src/supermarket/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@

# The value of ENV["DISABLE_HOST_HEADER_ATTACK"] will be parsed as string.
# Hence we need to convert string to boolean.
# It allows multiple hostname by specifying node['hostname'] attribute in .env file.
if ActiveModel::Type::Boolean.new.cast(ENV["DISABLE_HOST_HEADER_ATTACK"]) && ENV["ALLOWED_HOST"].present?
config.hosts << ENV["ALLOWED_HOST"]
ENV["ALLOWED_HOST"].split(",").each do |host|
config.hosts << host.strip
end
end
end

0 comments on commit 3f5f49b

Please sign in to comment.