Elasticquent
Elasticquent copied to clipboard
Failed to access when host url with username:password
I am using facetflow.io, a hosted elasticsearch. Their url have an API KEY prepend to the cluster url, such as:
https://apikey:@example.azure.facetflow.io
When I put in this URL to the config.hosts, facetflow returned error 401, authentication failed.
No problem when I was using aws elasticsearch, as they doesn't prepend any credential to the url.
So I wonder is this a problem with elasticquent or there are some problem with my server?
regards,
What does your config/elasticquent.php
look like?
This is my entire file for bonsai.io
:
return array(
/*
|--------------------------------------------------------------------------
| Custom Elasticsearch Client Configuration
|--------------------------------------------------------------------------
|
| This array will be passed to the Elasticsearch client.
| See configuration options here:
|
| http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html
*/
'config' => [
'hosts' => ['https://[hidden]:[hidden]@book-index-[hidden].ap-southeast-2.bonsai.io'],
'retries' => 1,
],
/*
|--------------------------------------------------------------------------
| Default Index Name
|--------------------------------------------------------------------------
|
| This is the index name that Elasticquent will use for all
| Elasticquent models.
*/
'default_index' => 'book-index',
);
This configuration works fine for me.
The configuration for Elasticquent w/ Facetflow is similar.
Go to your Security page inside Facetflow, and go to the access control page. Make sure if you are using a custom key (that is, anything but the unmodified default) that you click on the padlock, and ensure that there is enough access for that key to work:
Make note of the key on the left hand side:
That key will be used for your hosts config.
<?php
return array(
'config' => [
'hosts' => [
'https://1iHsUwgWkaE[hidden]:@elasticquent.east-us.azr.facetflow.io:443'
],
'retries' => 1,
],
);
Note that there is a colon (":") just before the at sign ("@").
You will realise that I have added the HTTPS port at the end of the host. This is to override the default inside Elasticsearch's library (which is 9200
, when it is not set)
@yaofong did this help?
do some people have experience with AWS Elasticsearch calls w/ Elasticquent ?