Opensearch server base url / web context

Is the a configuration (file) settings for setting base url.

We are running server Docker behind reverse-proxy and traffic is reverse-proxied to ES 9200 via web context name

So x.y.z.:9200 if rev proxied as x.x.x/search

So all responses from search server are ‘index “search” not found’. In there a config to tell API base url is “search/” not “/” ?

That’s up to your client library really. It should be transparent to OpenSearch (although you say “ES” I assume you mean OpenSearch).

yes, I mean to say OS, not ES (old habit).

And no, it is not at all “up to client”.

If the OS HTTP service is routed in the network from x.x.x:80/search/* → actual.server.ip:9200/{original URL path&parameters}

And as the OS server assumes it running in root web context “/” then OS interprets “/search” as API path parameter and says index “search” does not exist for every single request regardless of that the URL is as the URL always starts with /search

Usually there is a parameter in the application to set the “api.base.path”. Like in Spring Boot

server.servlet.context-path=/customer1

So that the REST API request mapping ignores that part of the request URL.
I case you are running multiple instanced on same web server or route via context. Or use multi-tenancy by the root contextt.

Not having this functionality in the application it leaves messing around with routing and rewriting the URL as only option. That is not always possible or desirable.

This is rudimentary basic feature of pretty much EVERY single application with REST API. It is the second most important server setting to any web service right after server port.

So far only reference to it I have been able to find is:Set API base Url | Elastic Cloud Enterprise Reference [3.4] | Elastic

But there is no mention if a configuration parameter for it exists.

Hey for the document you linked that is a part of their enterprise offering and it’s likely they are just doing the URL rewrite in their reverse proxy.

Since you already have a reverse proxy setup you should be able to do the rewrite in there to achieve the same effect. Here is a good article that covers doing that with Nginx.

https://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite

If you really need to have it done in OpenSearch you can open a feature request for it. I just checked the backlog and it looks like no one else has requested it yet.

Thank you. Having that as configuration parameter would be more convenient. And necessary in cases where changes to network routing are not possible.Naturally the actual routing is done the router or rev-proxy, but the setting would allow the application to work out of the box when this routing is used, We ready are using rewrite, I just was looking for better solution which could contain this problem to the OS server itself. I replaced nginx with Caddy years ago. Caddy server has every single feature of nginx commercial version and so much more. And Caddy is 100% OSS.

I abandoned nginx years ago.Due to the pay-wall it has. Using the nginx OSS version you soon discover that you need features are only available in commercial version. Just like most OSS + Commercial hybrid products, like ElasticSearch ;). Not to mention that in current political situation using nginx is risky, in both image and security. There is heavy involvement from the Russian leadership into the nginx company. The Russian government seized power over that company years ago, federal police assaulted nginx head offices in force in 2019, siting vague “copyright violations” excuses, threatening the owners with prison. Since then then nging company seems to be in very short leash by the Russian leadership. Ofc OSS is open but the feature pay-gate might put pressure to switching to the commercial black box version of the product.

Oh sorry, from your original post I thought this was an issue you were actively looking to solve. Sounds good though I would open a feature then and we can get some community feedback to see how many others are looking for similar functionality.

Open a Feature

Also, I wasn’t aware of the NGINX thing. I will check out Caddy :grin: I’ve not rolled a proxy in a while so probably worth checking out what they have to offer.