Rails - 机架攻击宝石油门与AWS弹性豆茎

问题描述 投票:0回答:1

我试图设置Rack Attack gem用于限制。但是,我使用aws弹性beanstalk,我发现由于负载平衡器,用户的IP地址对于所有请求都是相同的。有没有办法解决它并获得用户的IP或任何其他方式来设置它?这是我现在为Rack Attack gem编写的代码:

class Rack::Attack
    Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new

    Rack::Attack.throttle('req/ip', :limit => 10, :period => 10.second) do |req|
        req.ip
    end
end
ruby-on-rails amazon-web-services elastic-beanstalk throttling
1个回答
1
投票

You're looking for "How to configure a Proxy Protocol Support"

代理协议是一种Internet协议,用于从请求连接的源传送连接到请求连接的目标的连接信息。 Elastic Load Balancing使用代理协议版本1,它使用人类可读的标头格式。

Configure Proxy Protocol Support for Your Classic Load Balancer

内容

© www.soinside.com 2019 - 2024. All rights reserved.