【问题标题】:Rails - Rack Attack gem throttle with AWS elastic beanstalkRails - 带有 AWS 弹性豆茎的 Rack Attack gem 节流阀
【发布时间】:2018-06-12 13:08:43
【问题描述】:

我已尝试设置 Rack Attack gem 进行节流。但是,我使用 aws elastic 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 amazon-elastic-beanstalk throttling


    【解决方案1】:

    您正在寻找“如何配置代理协议支持”

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

    Configure Proxy Protocol Support for Your Classic Load Balancer

    内容

    【讨论】:

    • 非常感谢!正是我想要的!
    猜你喜欢
    • 1970-01-01
    • 2018-02-25
    • 2017-09-01
    • 2019-04-21
    • 2014-12-22
    • 2013-08-02
    • 2023-04-04
    • 2015-03-20
    • 2015-07-28
    相关资源
    最近更新 更多