Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path option to Extended Host Configuration #776

Closed
SirkoS opened this issue Jun 24, 2018 · 3 comments
Closed

Add path option to Extended Host Configuration #776

SirkoS opened this issue Jun 24, 2018 · 3 comments

Comments

@SirkoS
Copy link
Contributor

SirkoS commented Jun 24, 2018

Summary of problem or feature request

In my setup, Elastic is proxied by an Apache HTTP to some subfolder. So basically instead of somedomain.com the instance is listening on somedomain.com/elastic It uses the standard HTTP port 80. As long as I connect via HTTP requests directly, everything works well, but the problems start, when trying to connect via PHP.

The Extended Host Configuration section in the documentation does not cover this case. So I tried different options as follows to no avail:

input-url built request-url
http://somedomain.com/elastic http://somedomain.com:9200/elastic/_stats
[ "host" => "vis.inf-bb.uni-jena.de/es", "scheme" => "http", "port" => "80" ] http://somedomain.com/elastic:80/_stats

I finally got it to work using the simple URL http://somedomain.com:80/elastic.

I think, that the extended host configuration should cover cases, where a path is involved by introducing another path property there, which would also be in line with the referenced parse_url() output.

Code snippet of problem

To investigate the errors I used the following code

<?php
require 'vendor/autoload.php';

$hosts = [  $url ];
$client = Elasticsearch\ClientBuilder::create()->setHosts($hosts)->build();

try {
  $results = $client->indices()->stats( [ 'client' => [ 'verbose' => true ] ] );
  var_dump( $results );
}
catch (Exception $e) {
  $last = $client->transport->getLastConnection()->getLastRequestInfo();
  $last['response']['error'] = [];
  var_dump( $last );
}

System details

  • OS Version: Debian 9.4 (server) & Windows 10 ("client")
  • PHP Version: 7.2.4
  • ES-PHP client version: 6.0.1
  • Elasticsearch version: 6.2.4
@SirkoS SirkoS changed the title Connect to a Elastic through proxy at subfolder Add path option to Extended Host Configuration Jun 24, 2018
@polyfractal
Copy link
Contributor

Seems reasonable to me. I'm a bit short on cycles at the moment, not sure when I'll get to this. If you'd like to send a PR I'd be happy to review it, otherwise I'll try to get to this enhancement soonish :)

Sorry for the pain that you had to go through to get that working!

@SirkoS
Copy link
Contributor Author

SirkoS commented Jun 28, 2018

I'll try to give it a shot in the next days. Will report back on my progress.

@SirkoS
Copy link
Contributor Author

SirkoS commented Jun 30, 2018

Turns out I was not trying hard enough. path is actually a supported property (don't know why I didn't try that as well).

Submitted a pull request, so that the list of possible parameters for the extended host configuration is explicitly referenced in the docs by a pointer to the respective PHP docs on parse_url().

@SirkoS SirkoS closed this as completed Jun 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants