Search code examples
spring-bootspring-data-elasticsearch

spring data elasticsearch propery to reach elasticsearch behind a reverse proxy (URI with a web context-path)


I am using spring boot 2.4.6 alongside data elasticsearch.

I would like to set my config for elasticsearch as below as the server is behing a reverseproxy that rewrites the URL.

spring.elasticsearch.rest.uris=https://admin-integration.hello.com/elasticsearch/api
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=blabla

and I get

java.net.UnknownHostException: admin-integration.hello.com/elasticsearch/api

How can I deal with that ? I don't find any relevant property available in the config. Any clue ?


Solution

  • Spring Data Elasticsearch configuration can take a withPathPrefix(String) parameter (see the docs at https://docs.spring.io/spring-data/elasticsearch/docs/4.2.4/reference/html/#elasticsearch.clients.configuration)

    This is a Spring Boot problem, as these properties are processed by Spring Boot to setup the Spring Data Elasticsearch configuration.