class ActionDispatch::RemoteIp

def initialize(app, check_ip_spoofing = true, custom_proxies = nil)

IP addresses, and return the one that you want.
+custom_trusted+ parameter. That way, the middleware will ignore those
servers after it. If your proxies aren't removed, pass them in via the
middle (or at the beginning) of the X-Forwarded-For list, with your proxy
to +TRUSTED_PROXIES+. Any proxy setup will put the value you want in the
instead of +TRUSTED_PROXIES+, or a string, which will be used in addition
The +custom_trusted+ argument can take a regex, which will be used

incorrect or confusing way (like AWS ELB).
clients (like WAP devices), or behind proxies that set headers in an
address. It makes sense to turn off this check on sites aimed at non-IP
is raised if it looks like the client is trying to lie about its own IP
The +check_ip_spoofing+ option is on by default. When on, an exception

Create a new +RemoteIp+ middleware instance.
def initialize(app, check_ip_spoofing = true, custom_proxies = nil)
  @app = app
  @check_ip = check_ip_spoofing
  @proxies = case custom_proxies
    when Regexp
      custom_proxies
    when nil
      TRUSTED_PROXIES
    else
      Regexp.union(TRUSTED_PROXIES, custom_proxies)
    end
end