Elasticsearch with HTTPS POST/PUT/GET request - elasticsearch

Is there any document available to setup Elasticsearch to serve connection over SSL ?. And is the option available on ELS ?.
Ex : curl -XGET https://localhost:9200/
Thanks.

You can setup your code to call SSL. What language are you using? Are you using a custom client or one provided by ElasticSearch (Find a list of clients supplied by ElasticSearch here)? If you are using a client you can configure them to use SSL (Here is an example for PHP's client).
I use SSL by using PHP's curl library. I do not use an clients, but instead a custom client. The following will list the stats of ElasticSearch from an SSL connection.
<?php
$ch = curl_init('https://localhost:9200/_stats');
curl_exec($ch); // this outputs to the browser.
// You can capture it using PHP's output buffer
// http://php.net/manual/en/function.ob-start.php
curl_close($ch);

Related

how to connect or acquire a connection to a blob storage via outbound proxy

curl -v -X GET 'https://outboundproxy.xx.net:8443/<Container_name>/<SAS>Token' -H
'Host: Azurestorage.blob.core.windows.net' -H "Rest of the curl
headers"
We have a outbound proxy inplace and all of the external connection has to go via an 'https://outboundproxy.xx.net:8443'. Hence, In the above curl command i have used host header to pass the actual storage account base url.
Now, I want to replicate it using the python Azure blob SDK module but I am not sure how to structure the account url parameter. Any pointer or hint will be helpful
Now, I want to replicate it using the python Azure blob SDK module but I am not sure how to structure the account url parameter. Any pointer or hint will be helpful
As per discussion between jalauzon and Jagadishbobadeg, adding gist as a community wiki to help community members who might face a similar issue.
While trying to add SAS token in a connection string, use SharedAccessSignature
Instead of using container name in URL, just use root endpoint URL.
from azure.storage.blob import BlobServiceClient
conn = 'DefaultEndpointsProtocol=https;BlobEndpoint=https://********.net:8443/;AccountName=<StorageName only>;SharedAccessSignature=sp=rl&st=2022-04-08T11:54:32Z&se=2022-05-08T19:54:32Z&spr=https&sv=2020-08-04&sr=c&sig=*****************************'
blob_service_client = BlobServiceClient.from_connection_string(conn)
headers = {'Host': '************************.blob.core.windows.net'}
container_client = blob_service_client.get_container_client(<Container_Name>)
containers = container_client.list_blobs(headers=headers)
Reference: Acquire a connection to a Blob storage via outbound reverse proxy settings

Is it possible to make such a proxy usage?

I`m wondering if it is possible to implement following:
I have some service in GO (used for Firebase Cloud Messaging) it uses go package from firebase (firebase.google.com/go/v4) to send messages. This packge sends https requests. And One of them is to https://oauth2.googleapis.com/token to get token.
I can't change code in Firebase go-package, but I need to use proxy, that is why before sending message I need to set HTTPS_PROXY environment variable to my proxy address. It works fine.
Now I need to do some automatic tests and I have an emulator that has /token endpoint and return a valid token as response. Is it possible to use some kind of proxy that can redirect https requests to my emulators endpoint so that all requests to https://oauth2.googleapis.com/token should be redirected to my emulators endpoint /token?
And another question is there are any possible problems because of HTTPS ?
Is it possible to get rid of https and use only http after the proxy?
Found following solution:
Firebase Cloud Messaging package uses clone default transport to create http.client under the hood.
So we can configure http.DefaultTransport before calling app.Messaging(ctx) and set up any parameters we need (proxy, insecureSkipVerify ...).
So no problems at all.

How to specify tenant in API request to Elasticsearch?

I need to get all indices from Global tenant in Kibana 6.7.1:
GET /api/saved_objects/_find?type=index-pattern
How can I specify tenancy?
Not sure what plugin you are using for Kibana multi tenancy.
But if you are using SearchGuard Kibana security plugin, you can use the HTTP Header curl -H 'securitytenant: privateTenant'
If you are using opendistro Kibana security plugin, you can use the HTTP Header curl -H 'sgtenant: privateTenant'

Call an external URL

I need to call an external URL and check the status in laravel 5.4.
I've looked at using Guzzle:
use GuzzleHttp\Client;
....
$client = new Client();
$res = $client->get('some-external-url');
dd($res->getBody());
But with dusk testing and other new things in 5.4, is there a better method now? Also guzzle doesnt appear to be a dependency anymore.
Why don't you Curl.
Curl allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
There are N Number of Curl Libraries for Laravel
First is anlutro/php-curl .
Second is ixudra/curl

Curl Request not working on new sever

Recently we have moved our website on new server and after that curl requests has stopped working. Our website is on Magento and we are using a plugin which sends request to a webservice using curl.
This code is working on local system and also in old server but on new server curl send the blank response.
I have also print the curl_error output and it is saying "couldn't connect to host". Please let me know if anyone has face this same issue.
is very explicit ... it means Failed to connect() to host or proxy.
The following code would work on any system:
$ch = curl_init("http://google.com"); // initialize curl handle
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
print($data);
If you can not see google page then .. your URL is wrong or you have some firewall or restriction issue.

Resources