Elasticsearch问题:无法连接AWS Elasticsearch服务

根据

我有一个关于配置elasticsearch以连接AWS Elasticsearch服务以在生产中运行项目的问题。我的Gemfile:

    gem 'searchkick'
    gem 'faraday_middleware-aws-signers-v4'
    gem 'aws-sdk', '~> 2'
    gem "elasticsearch", ">= 1.0.15"

参考:https : //github.com/ankane/searchkick

我的config / initializers / elasticsearch.rb文件:

    require "faraday_middleware/aws_signers_v4"
    ENV["ELASTICSEARCH_URL"] = "https://search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com/"

       Searchkick.client = Elasticsearch::Client.new(
       url: ENV["ELASTICSEARCH_URL"],
        transport_options: {request: {timeout: 10}}
       ) do |f|
       f.request :aws_signers_v4, {credentials: Aws::Credentials.new(Rails.application.secrets.aws_access_key_id, Rails.application.secrets.aws_secret_access_key),
       service_name: "es",
       region: "ap-southeast-1"
     }
   end

当我运行“ rake searchkick:reindex:all”时,它显示错误:

Elasticsearch :: Transport :: Transport :: Errors :: Forbidden:[403] {“ message”:“我们计算出的请求签名与您提供的签名不匹配。请检查您的AWS Secret Access密钥和签名方法。请查阅服务文档\ n \ n此请求的规范字符串应为\ n'GET \ n / _aliases \ n \ naccept-encoding:gzip; q = 1.0,deflate; q = 0.6,identity; q = 0.3 \ nhost: search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com \ nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852zz / n:2016-n \ n-ac-z \ n-en-ac-t-en-en;编码为:09-c-en-ac; n-ams-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852z sha256; x-amz-date \ ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\ n \ n字符串签名应该已经\ n'AWS4-HMAC-SHA256 \ n20160914T095023Z \ n20160914 / ap-southeast-1 / es / aws4_request \ n47bc69b4440a13aeac990b8c6c49934f1dcc4693bbbda577bfdeb02e685c507b'\ n“}”

任何人都可以帮助我!谢谢!

德米特里·布德尼克

您应该从 ELASTICSEARCH_URL

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章