summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-25 10:33:12 +0200
committerRémy Coutable <remy@rymai.me>2016-07-25 11:04:32 +0200
commit1e8f2ccfad7c82c179af1bd68f20797e4730abef (patch)
treebc776f282b9196f175f32239e1143b0368acf673 /config
parent7b5fb0ce164bd732e4a6fed508f85a2868bc4bf4 (diff)
downloadgitlab-ce-1e8f2ccfad7c82c179af1bd68f20797e4730abef.tar.gz
Merge branch 'reject-invalid-trusted-proxies'
See !5454. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'config')
-rw-r--r--config/initializers/trusted_proxies.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb
index df4a933e22f..30770b71e24 100644
--- a/config/initializers/trusted_proxies.rb
+++ b/config/initializers/trusted_proxies.rb
@@ -11,6 +11,12 @@ module Rack
end
end
+gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy|
+ begin
+ IPAddr.new(proxy)
+ rescue IPAddr::InvalidAddressError
+ end
+end.compact
+
Rails.application.config.action_dispatch.trusted_proxies = (
- [ '127.0.0.1', '::1' ] + Array(Gitlab.config.gitlab.trusted_proxies)
-).map { |proxy| IPAddr.new(proxy) }
+ [ '127.0.0.1', '::1' ] + gitlab_trusted_proxies)