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.
Classes and Modules
Public Class methods
configure(app, header)
[show source]
# File lib/roda/plugins/ip_from_header.rb 19 def self.configure(app, header) 20 app.opts[:ip_from_header_env_key] = "HTTP_#{header.upcase.tr('-', '_')}".freeze 21 end