Module: Roda::RodaPlugins::IPFromHeader
- Defined in:
- lib/roda/plugins/ip_from_header.rb
Overview
The ip_from_header plugin allows for overriding request.ip to return the value contained in a specific header. This is useful when the application is behind a proxy that sets a specific header, especially when the proxy does not use a fixed IP address range. Example showing usage with Cloudflare:
plugin :ip_from_header, "CF-Connecting-IP"
This plugin assumes that if the header is set, it contains a valid IP address, it does not check the format of the header value, just as Rack::Request#ip does not check the IP address it returns is actually valid.
Defined Under Namespace
Modules: RequestMethods
Class Method Summary collapse
Class Method Details
.configure(app, header) ⇒ Object
19 20 21 |
# File 'lib/roda/plugins/ip_from_header.rb', line 19 def self.configure(app, header) app.opts[:ip_from_header_env_key] = "HTTP_#{header.upcase.tr('-', '_')}".freeze end |