Rails comes with a range of middleware which is included by default. But what if I want to pass arguments to the middleware? For example, ActionDispatch::RemoteIp
takes two optional arguments: ip_spoofing_check
and custom_proxies
. How do I reconfigure the already included ActionDispatch::RemoteIp
middleware but passing in my own value for custom_proxies
?
ActionDispatch::RemoteIp
checks for IP spoofing attacks and gets valid client_ip from request headers. Configurable with theconfig.action_dispatch.ip_spoofing_check
, andconfig.action_dispatch.trusted_proxies
options.
- Rails Guides - Configuring Middleware
In fact most of the middleware has setters so that you can reconfigure it instead of having to change the initialization arguments.