1
我知道你可以使用Elastica客户端,像这样做:如何在官方Elasticsearch PHP客户端中设置代理?
$client = new \Elastica\Client(array(
'host' => 'my host',
'port' => '9200',
'proxy' => 'my proxy'
));
,但我想如果可能的话使用官方客户端。 我根据文档here建立了连接。
$hosts = [
[
'host' => 'my host',
'port' => '9200',
'scheme' => 'http',
'user' => 'my user',
'pass' => 'my pass'
]
];
$client = Elasticsearch\ClientBuilder::create()
->setHosts($hosts)
->build();
但是,关于如何设置代理的文档中没有任何内容。可能吗?
顺便说一句,我见过this question,但它已过时,并不适用于当前版本。
这工作!只是注意不过,如果你还需要设置代理服务器的端口,使用: ' '卷曲'=> [ CURLOPT_PROXY => “代理”, CURLOPT_PROXYPORT => “端口” ]' – mrbubblesort