def remote_addr
      if respond_to?(:remote_ip)
        __send__(:remote_ip)  # for Rails
      elsif respond_to?(:ip)
        __send__(:ip)         # for Rack
      else
        if env['HTTP_X_FORWARDED_FOR']
          env['HTTP_X_FORWARDED_FOR'].split(',').pop
        else
          env['REMOTE_ADDR']
        end
      end
    end
def remote_addr
      if respond_to?(:remote_ip)
        __send__(:remote_ip)  # for Rails
      elsif respond_to?(:ip)
        __send__(:ip)         # for Rack
      else
        if env['HTTP_X_FORWARDED_FOR']
          env['HTTP_X_FORWARDED_FOR'].split(',').pop
        else
          env['REMOTE_ADDR']
        end
      end
    end
for reverse proxy.