ruby-on-rails - searchkick代理设置ruby on rails

标签 ruby-on-rails elasticsearch proxy searchkick

我正在使用searchkick gem(https://github.com/ankane/searchkick),(它使用elasticsearch)在我的rails应用程序中执行搜索操作。

我在代理服务器后面。

rake searchkick:reindex CLASS=ClassName

由于代理而引发HTTP 403错误。

有谁知道如何为searchkick设置代理设置

编辑:

我认为问题是searchkick使用我的环境代理设置连接到本地主机。

有没有一种方法可以指定searchkick绕过本地地址的代理而不删除我的所有系统代理设置?

最佳答案

问题是请求被重定向到代理,在这种情况下是错误的。您必须添加两个环境变量来禁用本地主机请求的代理:

export no_proxy=0.0.0.0,127.0.0.1,localhost
export NO_PROXY=0.0.0.0,127.0.0.1,localhost

Searchkick使用curl来向Elasticsearch API发出请求,并且curl从no_proxy环境变量读取代理异常。
下次如果您遇到此类问题,请先检查以下步骤:
curl localhost # Observe the response if its coming from proxy try the next step
curl --noproxy "*" localhost # Do not send request to the proxy
echo $no_proxy # Check that you have the right environment variable value

关于ruby-on-rails - searchkick代理设置ruby on rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33080344/

相关文章:

Elasticsearch 集群在重新分片期间失败

proxy - 如何让两个 Telethon 客户端分别使用不同的 IP

google-chrome - Chrome 要求对我打开的每个页面进行代理身份验证,IE 不会

ruby-on-rails - Rails 4 传输响应

ruby-on-rails - Bundler 找不到 gem "spring"的兼容版本

elasticsearch - Kibana 连接 Elasticsearch 失败

c# - 在具有不同根相对路径的代理后面运行 ASP.NET MVC 应用程序

css - rails 应用程序 : pipeline asset not working as expected

javascript - jquery 多重选择 x Rails 编辑操作

elasticsearch - 使用 Hive/Qubole 插入 ElasticSearch