【问题标题】:Rails 5 Securing Action Cable with redisRails 5 使用 redis 固定动作电缆
【发布时间】:2017-05-11 18:29:26
【问题描述】:

如何使用 redis 和 action Cable 来保护 rails 5 中的套接字连接?

我们可以在里面添加什么配置

config/redis.rb

在 Redis 中添加密码验证。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 redis actioncable


    【解决方案1】:
    production:
      url: redis://:{redis_auth}@{redis_host}:{redis_port}/1
    

    在 {redis_auth} 之前注意 ':'。

    【讨论】:

    • 我在使用这种方法时得到一个 URI::InvalidURIError(bad URI(is not URI?) 错误。这是否意味着某些特定字符不能在 redis 密码中?跨度>
    • @apod 我相信会有这样的问题
    • 顺便说一句,如果您的密码包含任何不是 URI 安全的字符(对我来说,/ 字符是罪魁祸首),解决方案是使用 URI.encode(your_password, /\W/) 并将其用作 redis_auth 变量。
    • 为什么在 // 之后
    • @Prime 它是通用 URI 语法的一部分。 URI = scheme:[//authority]path[?query][#fragment] 其中 authority = [userinfo@]host[:port] 和 userinfo = username:password。这里省略了用户名(redis 将其解释为“默认用户”),但冒号仍然是必需的,以指示密码部分如下。
    【解决方案2】:

    我相信这些是目前唯一公开的选项:

    development: &development
      :url: redis://localhost:6379
      :host: localhost
      :port: 6379
      :timeout: 1
      :inline: true
    test: *development
    production: &production
      :url: redis://{redis_host}:{redis_port}/
      :host: {redis_host}
      :port: {redis_port}
      :password: {redis_password}
      :inline: true
      :timeout: 1
    

    【讨论】:

      猜你喜欢
      • 2018-07-29
      • 2017-05-27
      • 2018-04-20
      • 1970-01-01
      • 2016-11-23
      • 1970-01-01
      • 2021-01-28
      • 2017-09-15
      相关资源
      最近更新 更多