nextcloud / nextcloud/fulltextsearch

fulltextsearch Address of the Servlet needs to pass https, but converts to http

Open
#867 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
234
Forks
64
Avg merge
6h 18m
Merged PRs (30d)
10

Description

I am using ...aws.elastic-cloud.com:9243
the server applet is defined as
https://******************.eu-central-2.aws.elastic-cloud.com:9243/

So I enter exactly this string for "Address of the Servlet"
https://user:password@*****************.eu-central-2.aws.elastic-cloud.com:9243

the log files shows

:"Request: PUT http://user:password@*******************.eu-central-2.aws.elastic-cloud.com:9243/service_index/_doc/files%3A45307323?pipeline=attachment","userAgent":"--","version":"29.0.6.1","data":{"app":"fulltextsearch_elasticsearch","request":"{"[object]

which returns an error
{"reqId":"Ww4vhzZOpq7LjbtESUpN","level":3,"time":"2024-09-07T14:34:22+00:00","remoteAddr":"","user":"--","app":"fulltextsearch_elasticsearch","method":"","url":"--","message":"Retry 0: cURL error 56: Recv failure: Connection reset by peer (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://user:password@************.eu-central-2.aws.elastic-cloud.com:9243/service_index/_doc/files%3A45307323?pipeline=attachment","userAgent":"--","version":"29.0.6.1","data":{"app":"fulltextsearch_elasticsearch"},"id":"66dc66602286d"}

Hint:
this works
curl --user user:password -X GET "https://**************.eu-central-2.aws.elastic-cloud.com:9243/_cat/indices?v=true&s=index&pretty"

curl --user user:password -X GET "http://**************.eu-central-2.aws.elastic-cloud.com:9243/_cat/indices?v=true&s=index&pretty"

IMHO AWS elastic is not configured to handle http requests

as a quick fix I changed
lib/Vendor/Http/Discovery/Psr17Factory.php
to remove the error.
IMHO the prefix http or https must not be hard coded, but taken from the "Address of the Servlet"

176     private function buildUriFromGlobals(UriInterface $uri, array $server) : UriInterface
177     {
178         $uri = $uri->withScheme(!empty($server['HTTPS']) && 'off' !== \strtolower($server['HTTPS']) ? 'https' : 'http');
179         $hasPort = \false;
180         if (isset($server['HTTP_HOST'])) {
181 # fgf  $parts = \parse_url('http://' . $server['HTTP_HOST']);
182             $parts = \parse_url('https://' . $server['HTTP_HOST']);
183             $uri = $uri->withHost($parts['host'] ?? 'localhost');
184             if ($parts['port'] ?? \false) {
185                 $hasPort = \true;
186                 $uri = $uri->withPort($parts['port']);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/Vendor/Http/Discovery/Psr17Factory.php, especially buildUriFromGlobals() around the HTTP_HOST parsing shown in the issue. Reproduce the request against an HTTPS Elasticsearch endpoint and trace how the servlet address becomes the logged request URL. Done means HTTPS endpoints are requested with the correct scheme without breaking HTTP configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, php
Domain
backend, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.