Zend certified PHP/Magento developer

Setup Elasticsearch in Plesk (Nginx + Apache)

I have been trying to configure Elasticsearch in the Magento installation for a few days but I can’t get it to work completely, I see it close but there is always something that fails.

I installed Magento disabling this module but now I want to do it right and enable it again.

The server I am working on has Plesk installed and SSL active. It works in such a way that NGINX handles requests and sends them to Apache.

I have Elasticsearch configured and active on port 9200

systemctl status elasticsearch -> active

I have configured nginx to work correctly with SSL:

If I make a request without a user or password, it returns Error 401 (correct):

curl -i https://xx.xx.xx.xx:8080/_cluster/health


HTTP/1.1 401 Unauthorized
Server: nginx
Date: Wed, 14 Dec 2022 14:12:08 GMT
Content-Type: text/html
Content-Length: 172
Connection: keep-alive
WWW-Authenticate: Basic realm="Restricted"

<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx</center>
</body>
</html>

If I add the username and password to the request, it answers correctly:

curl -i -u user:password https://xx.xx.xx.xx:8080/_cluster/health

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 14 Dec 2022 14:12:51 GMT
Content-Type: application/json
Content-Length: 389
Connection: keep-alive
X-elastic-product: Elasticsearch

{"cluster_name":"elasticsearch","status":"green","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":2,"active_shards":2,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}

However, in the magento administration section (Stores -> Configuration -> Catalog) when trying to put this configuration, the message appears

No alive nodes found in your cluster

What am I forgetting?

MORE INFO

netstat -an | grep 9200
tcp6       0      0 :::9200                 :::*                    LISTEN     
tcp6       0      0 xx.xx.xx.xx:9200      xx.xx.xx.xx:51762     TIME_WAIT 

Netstat returns two services, I don’t know if this may be influencing.