My elasticsearch http endpoint has been fronted with a corporate reverse proxy and also it has a path prefix. I am in the process of migrating from Transport client to HighLevelHttpClient can someone help me how to configure the elastic http endpoint behind an reverse proxy?
here elastic is the reverse proxy path prefix
> $ curl -v http://localhost:9090/elastic
* STATE: INIT => CONNECT handle 0x6000579e0; line 1423 (connection #-5000) * Added connection 0. The cache now contains 1 members * STATE: CONNECT => WAITRESOLVE handle 0x6000579e0; line 1459 (connection #0) * Trying ::1... * TCP_NODELAY set * STATE: WAITRESOLVE => WAITCONNECT handle 0x6000579e0; line 1540 (connection #0) * Connected to localhost (::1) port 9090 (#0) * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x6000579e0; line 1592 (connection #0) * Marked for [keep alive]: HTTP default * STATE: SENDPROTOCONNECT => DO handle 0x6000579e0; line 1610 (connection #0) > GET /elastic HTTP/1.1 > Host: localhost:9090 > User-Agent: curl/7.56.1 > Accept: */* > * STATE: DO => DO_DONE handle 0x6000579e0; line 1689 (connection #0) * STATE: DO_DONE => WAITPERFORM handle 0x6000579e0; line 1814 (connection #0) * STATE: WAITPERFORM => PERFORM handle 0x6000579e0; line 1824 (connection #0) * HTTP 1.1 or later with persistent connection, pipelining supported < HTTP/1.1 200 OK < Connection: keep-alive < Transfer-Encoding: chunked < Content-Type: application/json;charset=UTF-8 < X-Application-Context: company-proxy:9090 < Date: Sat, 27 Jan 2018 14:23:23 GMT < { "name" : "node-1", "cluster_name" : "my-application", "cluster_uuid" : "1K3Am20jSQ2KtALLgXvIXA", "version" : { "number" : "6.1.2", "build_hash" : "5b1fea5", "build_date" : "2018-01-10T02:35:59.208Z", "build_snapshot" : false, "lucene_version" : "7.1.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } * STATE: PERFORM => DONE handle 0x6000579e0; line 1993 (connection #0) * multi_done * Connection #0 to host localhost left intact * Expire cleared
JAVA Config how to pass the URL (http://localhost:9090/elastic instead of host and port)
@Bean public RestHighLevelClient elasticClient() { return new RestHighLevelClient(RestClient.builder( new HttpHost(elastichost, elasticport, DEFAULT_SCHEME_NAME))); }