简体   繁体   English

在Elasticsearch-php客户端上使用https

[英]using https with elasticsearch-php client

I am currently trying to connect to my elastic search cluster using the php elasticsearch client 我目前正在尝试使用php elasticsearch客户端连接到我的弹性搜索集群

I am having trouble using an https endpoint for this. 我在为此使用https端点时遇到麻烦。 I have my cluster behind a load balancer with a VIP in front, it is using Apache authentication and is on port 443. The trouble I am running into is that the config for the client seems to be parsing the hosts and removes https:// from the host name. 我的群集位于负载均衡器的后面,前端带有VIP,它使用Apache身份验证,并且位于端口443上。我遇到的问题是客户端的配置似乎正在解析主机并删除https://从主机名。 this results in the client always trying to connect over port 80. I have tried adding :443 to the host name but I am then getting a curl error "empty reply from server". 这导致客户端始终尝试通过端口80连接。我曾尝试将:443添加到主机名,但随后收到卷曲错误“来自服务器的空回复”。 I know that this server has access (no firewall blocking) because i can manually make the curl call using https://myelasticsearch.com . 我知道该服务器具有访问权限(没有防火墙阻止),因为我可以使用https://myelasticsearch.com手动进行curl调用。

My question is, is there a way to specify the protocol to make the request over using this client? 我的问题是,是否可以指定一种协议来使用此客户端发出请求? if not, where in the source is the parsing of the host array happening? 如果不是,主机数组的解析在源代码中的何处发生?

I have found a temporary solution, in src/Elasticsearch/Connections/AbstractConnection.php there is a defined transportSchema variable that is set to http . 我找到了一个临时解决方案,在src/Elasticsearch/Connections/AbstractConnection.php有一个已定义的transportSchema变量,该变量设置为http I changed this to https and also added the :443 to my host in the config and it works! 我将其更改为https并且还在配置中将:443添加到主机中,它可以正常工作!

Just as an update to this question (in case anyone stumbles into it), this bug was fixed in Elasticsearch-PHP v1.1.0. 就像对此问题的更新(以防万一有人偶然发现)一样,此错误已在Elasticsearch-PHP v1.1.0中修复。 You can specify https in the host now to use SSL: 您现在可以在主机中指定https以使用SSL:

$params = array();
$params['hosts'] = array (
    'https://localhost',        // SSL to localhost
    'https://192.168.1.3:9200'  // SSL to IP + Port
);

$client = new Elasticsearch\Client($params);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM