From 61aee0006eec95f47ca0a0c75f3ccf4151516b4a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 22 Jan 2017 21:01:28 +0100 Subject: [PATCH] Override Rack::Request to use the same trusted proxy settings as Rails --- config/initializers/trusted_proxies.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 config/initializers/trusted_proxies.rb diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb new file mode 100644 index 00000000000..27e9ee03961 --- /dev/null +++ b/config/initializers/trusted_proxies.rb @@ -0,0 +1,7 @@ +module Rack + class Request + def trusted_proxy?(ip) + Rails.application.config.action_dispatch.trusted_proxies.any? { |proxy| proxy === ip } + end + end +end