Skip to content

Commit 1bf6dc0

Browse files
authored
Add config.hosts and config.host_authorization to new app templates (rails#47447)
5c830a8 adds an "/up" endpoint to help LB and uptime monitors. DNS rebindings sometimes get in the way of it. Suggesting settings for both `hosts` and` host_authorization` help reduce this friction.
1 parent 136066f commit 1bf6dc0

File tree

1 file changed

+8
-0
lines changed
  • railties/lib/rails/generators/rails/app/templates/config/environments

1 file changed

+8
-0
lines changed

railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,12 @@ Rails.application.configure do
100100
# Do not dump schema after migrations.
101101
config.active_record.dump_schema_after_migration = false
102102
<%- end -%>
103+
104+
# Enable DNS rebinding protection and other `Host` header attacks.
105+
# config.hosts = [
106+
# "example.com", # Allow requests from example.com
107+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
108+
# ]
109+
# Skip DNS rebinding protection for the default health check endpoint.
110+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
103111
end

0 commit comments

Comments
 (0)